@danielx/civet 0.5.52 → 0.5.54
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 +115 -60
- package/dist/civet +1 -0
- package/dist/main.js +115 -60
- package/dist/main.mjs +115 -60
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -429,6 +429,7 @@ ${input.slice(result.pos)}
|
|
|
429
429
|
Program,
|
|
430
430
|
TopLevelStatement,
|
|
431
431
|
ExtendedExpression,
|
|
432
|
+
SingleLineExtendedExpression,
|
|
432
433
|
NonPipelineExtendedExpression,
|
|
433
434
|
NonAssignmentExtendedExpression,
|
|
434
435
|
ExpressionizedStatement,
|
|
@@ -741,6 +742,7 @@ ${input.slice(result.pos)}
|
|
|
741
742
|
__,
|
|
742
743
|
Whitespace,
|
|
743
744
|
ExpressionDelimiter,
|
|
745
|
+
SimpleStatementDelimiter,
|
|
744
746
|
StatementDelimiter,
|
|
745
747
|
SemicolonDelimiter,
|
|
746
748
|
NonIdContinue,
|
|
@@ -1270,6 +1272,30 @@ ${input.slice(result.pos)}
|
|
|
1270
1272
|
return result;
|
|
1271
1273
|
}
|
|
1272
1274
|
}
|
|
1275
|
+
var SingleLineExtendedExpression$0 = NonAssignmentExtendedExpression;
|
|
1276
|
+
var SingleLineExtendedExpression$1 = SingleLineAssignmentExpression;
|
|
1277
|
+
function SingleLineExtendedExpression(state) {
|
|
1278
|
+
let eventData;
|
|
1279
|
+
if (state.events) {
|
|
1280
|
+
const result = state.events.enter?.("SingleLineExtendedExpression", state);
|
|
1281
|
+
if (result) {
|
|
1282
|
+
if (result.cache)
|
|
1283
|
+
return result.cache;
|
|
1284
|
+
eventData = result.data;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
if (state.tokenize) {
|
|
1288
|
+
const result = $TOKEN("SingleLineExtendedExpression", state, SingleLineExtendedExpression$0(state) || SingleLineExtendedExpression$1(state));
|
|
1289
|
+
if (state.events)
|
|
1290
|
+
state.events.exit?.("SingleLineExtendedExpression", state, result, eventData);
|
|
1291
|
+
return result;
|
|
1292
|
+
} else {
|
|
1293
|
+
const result = SingleLineExtendedExpression$0(state) || SingleLineExtendedExpression$1(state);
|
|
1294
|
+
if (state.events)
|
|
1295
|
+
state.events.exit?.("SingleLineExtendedExpression", state, result, eventData);
|
|
1296
|
+
return result;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1273
1299
|
var NonPipelineExtendedExpression$0 = NonAssignmentExtendedExpression;
|
|
1274
1300
|
var NonPipelineExtendedExpression$1 = NonPipelineAssignmentExpression;
|
|
1275
1301
|
function NonPipelineExtendedExpression(state) {
|
|
@@ -1967,20 +1993,7 @@ ${input.slice(result.pos)}
|
|
|
1967
1993
|
}
|
|
1968
1994
|
}
|
|
1969
1995
|
var AssignmentExpression$0 = PipelineExpression;
|
|
1970
|
-
var AssignmentExpression$1 =
|
|
1971
|
-
var ws = $1;
|
|
1972
|
-
var tail = $2;
|
|
1973
|
-
if (ws.length) {
|
|
1974
|
-
if (tail.children && tail.type !== "IterationExpression") {
|
|
1975
|
-
return {
|
|
1976
|
-
...tail,
|
|
1977
|
-
children: [...ws, ...tail.children]
|
|
1978
|
-
};
|
|
1979
|
-
}
|
|
1980
|
-
return $0;
|
|
1981
|
-
}
|
|
1982
|
-
return tail;
|
|
1983
|
-
});
|
|
1996
|
+
var AssignmentExpression$1 = SingleLineAssignmentExpression;
|
|
1984
1997
|
var AssignmentExpression$2 = $S(__, AssignmentExpressionTail);
|
|
1985
1998
|
function AssignmentExpression(state) {
|
|
1986
1999
|
let eventData;
|
|
@@ -4908,7 +4921,7 @@ ${input.slice(result.pos)}
|
|
|
4908
4921
|
return result;
|
|
4909
4922
|
}
|
|
4910
4923
|
}
|
|
4911
|
-
var SingleLineStatements$0 = $TS($S($Q($S($
|
|
4924
|
+
var SingleLineStatements$0 = $TS($S($Q($S($S($E(_), $N(EOS)), Statement, SemicolonDelimiter)), $E($S($S($E(_), $N(EOS)), Statement, $E(SemicolonDelimiter)))), function($skip, $loc, $0, $1, $2) {
|
|
4912
4925
|
var stmts = $1;
|
|
4913
4926
|
var last = $2;
|
|
4914
4927
|
const children = [...stmts];
|
|
@@ -9384,7 +9397,12 @@ ${input.slice(result.pos)}
|
|
|
9384
9397
|
return result;
|
|
9385
9398
|
}
|
|
9386
9399
|
}
|
|
9387
|
-
var ExportVarDec$0 = $S(InsertVar, VariableDeclarationList)
|
|
9400
|
+
var ExportVarDec$0 = $TS($S(InsertVar, VariableDeclarationList), function($skip, $loc, $0, $1, $2) {
|
|
9401
|
+
return {
|
|
9402
|
+
...$2,
|
|
9403
|
+
children: [$1, ...$2.children]
|
|
9404
|
+
};
|
|
9405
|
+
});
|
|
9388
9406
|
function ExportVarDec(state) {
|
|
9389
9407
|
let eventData;
|
|
9390
9408
|
if (state.events) {
|
|
@@ -11207,6 +11225,30 @@ ${input.slice(result.pos)}
|
|
|
11207
11225
|
return result;
|
|
11208
11226
|
}
|
|
11209
11227
|
}
|
|
11228
|
+
var SimpleStatementDelimiter$0 = SemicolonDelimiter;
|
|
11229
|
+
var SimpleStatementDelimiter$1 = $Y(EOS);
|
|
11230
|
+
function SimpleStatementDelimiter(state) {
|
|
11231
|
+
let eventData;
|
|
11232
|
+
if (state.events) {
|
|
11233
|
+
const result = state.events.enter?.("SimpleStatementDelimiter", state);
|
|
11234
|
+
if (result) {
|
|
11235
|
+
if (result.cache)
|
|
11236
|
+
return result.cache;
|
|
11237
|
+
eventData = result.data;
|
|
11238
|
+
}
|
|
11239
|
+
}
|
|
11240
|
+
if (state.tokenize) {
|
|
11241
|
+
const result = $TOKEN("SimpleStatementDelimiter", state, SimpleStatementDelimiter$0(state) || SimpleStatementDelimiter$1(state));
|
|
11242
|
+
if (state.events)
|
|
11243
|
+
state.events.exit?.("SimpleStatementDelimiter", state, result, eventData);
|
|
11244
|
+
return result;
|
|
11245
|
+
} else {
|
|
11246
|
+
const result = SimpleStatementDelimiter$0(state) || SimpleStatementDelimiter$1(state);
|
|
11247
|
+
if (state.events)
|
|
11248
|
+
state.events.exit?.("SimpleStatementDelimiter", state, result, eventData);
|
|
11249
|
+
return result;
|
|
11250
|
+
}
|
|
11251
|
+
}
|
|
11210
11252
|
var StatementDelimiter$0 = SemicolonDelimiter;
|
|
11211
11253
|
var StatementDelimiter$1 = $S($Y($S(Samedent, $C($EXPECT($L92, fail, 'StatementDelimiter "("'), $EXPECT($L93, fail, 'StatementDelimiter "["'), $EXPECT($L94, fail, 'StatementDelimiter "`"'), $EXPECT($L54, fail, 'StatementDelimiter "+"'), $EXPECT($L55, fail, 'StatementDelimiter "-"'), $EXPECT($L50, fail, 'StatementDelimiter "*"'), $EXPECT($L51, fail, 'StatementDelimiter "/"'), ObjectLiteral))), InsertSemicolon);
|
|
11212
11254
|
var StatementDelimiter$2 = $Y(EOS);
|
|
@@ -15946,11 +15988,11 @@ ${input.slice(result.pos)}
|
|
|
15946
15988
|
return result;
|
|
15947
15989
|
}
|
|
15948
15990
|
}
|
|
15949
|
-
var CivetPrologue$0 = $T($S($EXPECT($R54, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(
|
|
15991
|
+
var CivetPrologue$0 = $T($S($EXPECT($R54, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(SimpleStatementDelimiter), $E(EOS)), function(value) {
|
|
15950
15992
|
var content = value[2];
|
|
15951
15993
|
return content;
|
|
15952
15994
|
});
|
|
15953
|
-
var CivetPrologue$1 = $T($S($EXPECT($R54, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(
|
|
15995
|
+
var CivetPrologue$1 = $T($S($EXPECT($R54, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(SimpleStatementDelimiter), $E(EOS)), function(value) {
|
|
15954
15996
|
var content = value[2];
|
|
15955
15997
|
return content;
|
|
15956
15998
|
});
|
|
@@ -16042,7 +16084,7 @@ ${input.slice(result.pos)}
|
|
|
16042
16084
|
return result;
|
|
16043
16085
|
}
|
|
16044
16086
|
}
|
|
16045
|
-
var UnknownPrologue$0 = $S($R$0($EXPECT($R54, fail, "UnknownPrologue /[\\t ]*/")), BasicStringLiteral, $TEXT(
|
|
16087
|
+
var UnknownPrologue$0 = $S($R$0($EXPECT($R54, fail, "UnknownPrologue /[\\t ]*/")), BasicStringLiteral, $TEXT(SimpleStatementDelimiter), EOS);
|
|
16046
16088
|
function UnknownPrologue(state) {
|
|
16047
16089
|
let eventData;
|
|
16048
16090
|
if (state.events) {
|
|
@@ -18104,9 +18146,6 @@ ${input.slice(result.pos)}
|
|
|
18104
18146
|
scopes.pop();
|
|
18105
18147
|
}
|
|
18106
18148
|
function createLetDecs(statements, scopes) {
|
|
18107
|
-
function hasDec(name) {
|
|
18108
|
-
return scopes.some((s) => s.has(name));
|
|
18109
|
-
}
|
|
18110
18149
|
function findVarDecs(statements2, decs) {
|
|
18111
18150
|
const declarationNames = gatherRecursive(
|
|
18112
18151
|
statements2,
|
|
@@ -18114,52 +18153,68 @@ ${input.slice(result.pos)}
|
|
|
18114
18153
|
).filter((node) => node.type === "Declaration").flatMap((node) => node.names);
|
|
18115
18154
|
return new Set(declarationNames);
|
|
18116
18155
|
}
|
|
18117
|
-
|
|
18118
|
-
|
|
18119
|
-
|
|
18120
|
-
|
|
18121
|
-
|
|
18122
|
-
|
|
18123
|
-
|
|
18156
|
+
let declaredIdentifiers = findVarDecs(statements);
|
|
18157
|
+
function hasDec(name) {
|
|
18158
|
+
return declaredIdentifiers.has(name) || scopes.some((s) => s.has(name));
|
|
18159
|
+
}
|
|
18160
|
+
function gatherBlockOrOther(statement) {
|
|
18161
|
+
return gatherNodes(statement, (s) => s.type === "BlockStatement" || s.type === "AssignmentExpression" || s.type === "Declaration").flatMap((node) => {
|
|
18162
|
+
if (node.type == "BlockStatement")
|
|
18163
|
+
return node.bare ? gatherBlockOrOther(node.expressions) : node;
|
|
18164
|
+
else if (node.children && node.children.length)
|
|
18165
|
+
return [...gatherBlockOrOther(node.children), node];
|
|
18166
|
+
else
|
|
18167
|
+
return [];
|
|
18168
|
+
});
|
|
18124
18169
|
}
|
|
18125
18170
|
let currentScope = /* @__PURE__ */ new Set();
|
|
18126
18171
|
scopes.push(currentScope);
|
|
18127
18172
|
const fnNodes = gatherNodes(statements, (s) => s.type === "FunctionExpression");
|
|
18128
18173
|
const forNodes = gatherNodes(statements, (s) => s.type === "ForStatement");
|
|
18129
|
-
|
|
18130
|
-
|
|
18131
|
-
|
|
18132
|
-
|
|
18133
|
-
|
|
18134
|
-
if (node.
|
|
18135
|
-
|
|
18136
|
-
|
|
18137
|
-
|
|
18138
|
-
|
|
18139
|
-
|
|
18140
|
-
|
|
18174
|
+
let targetStatements = [];
|
|
18175
|
+
for (const statement of statements) {
|
|
18176
|
+
const nodes = gatherBlockOrOther(statement);
|
|
18177
|
+
let undeclaredIdentifiers = [];
|
|
18178
|
+
for (const node of nodes) {
|
|
18179
|
+
if (node.type == "BlockStatement") {
|
|
18180
|
+
let block = node;
|
|
18181
|
+
let fnNode = fnNodes.find((fnNode2) => fnNode2.block === block);
|
|
18182
|
+
let forNode = forNodes.find((forNode2) => forNode2.block === block);
|
|
18183
|
+
if (fnNode != null) {
|
|
18184
|
+
scopes.push(new Set(fnNode.parameters.names));
|
|
18185
|
+
createLetDecs(block.expressions, scopes);
|
|
18186
|
+
scopes.pop();
|
|
18187
|
+
} else if (forNode != null) {
|
|
18188
|
+
scopes.push(new Set(forNode.declaration.names));
|
|
18189
|
+
createLetDecs(block.expressions, scopes);
|
|
18190
|
+
scopes.pop();
|
|
18191
|
+
} else
|
|
18192
|
+
createLetDecs(block.expressions, scopes);
|
|
18193
|
+
continue;
|
|
18194
|
+
}
|
|
18195
|
+
if (node.names == null)
|
|
18196
|
+
continue;
|
|
18197
|
+
let names = node.names.filter((name) => !hasDec(name));
|
|
18198
|
+
if (node.type == "AssignmentExpression")
|
|
18199
|
+
undeclaredIdentifiers.push(...names);
|
|
18200
|
+
names.forEach((name) => currentScope.add(name));
|
|
18201
|
+
}
|
|
18202
|
+
if (undeclaredIdentifiers.length > 0) {
|
|
18203
|
+
let indent = statement[0];
|
|
18204
|
+
let firstIdentifier = gatherNodes(statement[1], (node) => node.type == "Identifier")[0];
|
|
18205
|
+
if (undeclaredIdentifiers.length == 1 && statement[1].type == "AssignmentExpression" && statement[1].names.length == 1 && statement[1].names[0] == undeclaredIdentifiers[0] && firstIdentifier && firstIdentifier.names == undeclaredIdentifiers[0] && gatherNodes(statement[1], (node) => node.type === "ObjectBindingPattern").length == 0)
|
|
18206
|
+
statement[1].children.unshift(["let "]);
|
|
18207
|
+
else {
|
|
18208
|
+
let tail = "\n";
|
|
18209
|
+
if (gatherNodes(indent, (node) => node.token && node.token.endsWith("\n")).length > 0)
|
|
18210
|
+
tail = void 0;
|
|
18211
|
+
targetStatements.push([indent, "let ", undeclaredIdentifiers.join(", "), tail]);
|
|
18141
18212
|
}
|
|
18142
|
-
} else if (node.type == "Declaration") {
|
|
18143
|
-
if (node.children && node.children.length)
|
|
18144
|
-
createLetDecs(node.children, scopes);
|
|
18145
|
-
node.names.forEach((name) => currentScope.add(name));
|
|
18146
|
-
} else {
|
|
18147
|
-
let block = node;
|
|
18148
|
-
let fnNode = fnNodes.find((fnNode2) => fnNode2.block === block);
|
|
18149
|
-
let forNode = forNodes.find((forNode2) => forNode2.block === block);
|
|
18150
|
-
if (fnNode != null) {
|
|
18151
|
-
scopes.push(new Set(fnNode.parameters.names));
|
|
18152
|
-
createLetDecs(block.expressions, scopes);
|
|
18153
|
-
scopes.pop();
|
|
18154
|
-
} else if (forNode != null) {
|
|
18155
|
-
scopes.push(new Set(forNode.declaration.names));
|
|
18156
|
-
createLetDecs(block.expressions, scopes);
|
|
18157
|
-
scopes.pop();
|
|
18158
|
-
} else
|
|
18159
|
-
createLetDecs(block.expressions, scopes);
|
|
18160
18213
|
}
|
|
18214
|
+
targetStatements.push(statement);
|
|
18161
18215
|
}
|
|
18162
18216
|
scopes.pop();
|
|
18217
|
+
statements.splice(0, statements.length, targetStatements);
|
|
18163
18218
|
}
|
|
18164
18219
|
function gatherBindingCode(statements, opts) {
|
|
18165
18220
|
const thisAssignments = [];
|
|
@@ -18876,7 +18931,7 @@ ${input.slice(result.pos)}
|
|
|
18876
18931
|
({ parse } = import_parser.default);
|
|
18877
18932
|
({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
|
|
18878
18933
|
defaultOptions = {};
|
|
18879
|
-
uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationSuppressed", "ExtendedExpression", "FatArrowBody", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedObject", "NestedPropertyDefinitions", "NonSuppressedTrailingMemberExpressions", "ObjectLiteral", "PopIndent", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "Samedent", "ShortCircuitExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuppressIndentedApplication", "SuppressTrailingMemberProperty", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
|
|
18934
|
+
uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationSuppressed", "ExtendedExpression", "FatArrowBody", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedObject", "NestedPropertyDefinitions", "NonSuppressedTrailingMemberExpressions", "ObjectLiteral", "PopIndent", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuppressIndentedApplication", "SuppressTrailingMemberProperty", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
|
|
18880
18935
|
var compile = function(src, options = defaultOptions) {
|
|
18881
18936
|
var ast, code, events, filename, sm, srcMapJSON;
|
|
18882
18937
|
filename = options.filename || "unknown";
|
package/dist/civet
CHANGED
|
@@ -38,6 +38,7 @@ Options:
|
|
|
38
38
|
--js Strip out all type annotations; default to .jsx extension
|
|
39
39
|
--ast Print the AST instead of the compiled code
|
|
40
40
|
--inline-map Generate a sourcemap
|
|
41
|
+
--no-cache Disable compiler caching (slow, for debugging)
|
|
41
42
|
|
|
42
43
|
You can use - to read from stdin or (prefixed by -o) write to stdout.
|
|
43
44
|
|
package/dist/main.js
CHANGED
|
@@ -428,6 +428,7 @@ ${input.slice(result.pos)}
|
|
|
428
428
|
Program,
|
|
429
429
|
TopLevelStatement,
|
|
430
430
|
ExtendedExpression,
|
|
431
|
+
SingleLineExtendedExpression,
|
|
431
432
|
NonPipelineExtendedExpression,
|
|
432
433
|
NonAssignmentExtendedExpression,
|
|
433
434
|
ExpressionizedStatement,
|
|
@@ -740,6 +741,7 @@ ${input.slice(result.pos)}
|
|
|
740
741
|
__,
|
|
741
742
|
Whitespace,
|
|
742
743
|
ExpressionDelimiter,
|
|
744
|
+
SimpleStatementDelimiter,
|
|
743
745
|
StatementDelimiter,
|
|
744
746
|
SemicolonDelimiter,
|
|
745
747
|
NonIdContinue,
|
|
@@ -1269,6 +1271,30 @@ ${input.slice(result.pos)}
|
|
|
1269
1271
|
return result;
|
|
1270
1272
|
}
|
|
1271
1273
|
}
|
|
1274
|
+
var SingleLineExtendedExpression$0 = NonAssignmentExtendedExpression;
|
|
1275
|
+
var SingleLineExtendedExpression$1 = SingleLineAssignmentExpression;
|
|
1276
|
+
function SingleLineExtendedExpression(state) {
|
|
1277
|
+
let eventData;
|
|
1278
|
+
if (state.events) {
|
|
1279
|
+
const result = state.events.enter?.("SingleLineExtendedExpression", state);
|
|
1280
|
+
if (result) {
|
|
1281
|
+
if (result.cache)
|
|
1282
|
+
return result.cache;
|
|
1283
|
+
eventData = result.data;
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
if (state.tokenize) {
|
|
1287
|
+
const result = $TOKEN("SingleLineExtendedExpression", state, SingleLineExtendedExpression$0(state) || SingleLineExtendedExpression$1(state));
|
|
1288
|
+
if (state.events)
|
|
1289
|
+
state.events.exit?.("SingleLineExtendedExpression", state, result, eventData);
|
|
1290
|
+
return result;
|
|
1291
|
+
} else {
|
|
1292
|
+
const result = SingleLineExtendedExpression$0(state) || SingleLineExtendedExpression$1(state);
|
|
1293
|
+
if (state.events)
|
|
1294
|
+
state.events.exit?.("SingleLineExtendedExpression", state, result, eventData);
|
|
1295
|
+
return result;
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1272
1298
|
var NonPipelineExtendedExpression$0 = NonAssignmentExtendedExpression;
|
|
1273
1299
|
var NonPipelineExtendedExpression$1 = NonPipelineAssignmentExpression;
|
|
1274
1300
|
function NonPipelineExtendedExpression(state) {
|
|
@@ -1966,20 +1992,7 @@ ${input.slice(result.pos)}
|
|
|
1966
1992
|
}
|
|
1967
1993
|
}
|
|
1968
1994
|
var AssignmentExpression$0 = PipelineExpression;
|
|
1969
|
-
var AssignmentExpression$1 =
|
|
1970
|
-
var ws = $1;
|
|
1971
|
-
var tail = $2;
|
|
1972
|
-
if (ws.length) {
|
|
1973
|
-
if (tail.children && tail.type !== "IterationExpression") {
|
|
1974
|
-
return {
|
|
1975
|
-
...tail,
|
|
1976
|
-
children: [...ws, ...tail.children]
|
|
1977
|
-
};
|
|
1978
|
-
}
|
|
1979
|
-
return $0;
|
|
1980
|
-
}
|
|
1981
|
-
return tail;
|
|
1982
|
-
});
|
|
1995
|
+
var AssignmentExpression$1 = SingleLineAssignmentExpression;
|
|
1983
1996
|
var AssignmentExpression$2 = $S(__, AssignmentExpressionTail);
|
|
1984
1997
|
function AssignmentExpression(state) {
|
|
1985
1998
|
let eventData;
|
|
@@ -4907,7 +4920,7 @@ ${input.slice(result.pos)}
|
|
|
4907
4920
|
return result;
|
|
4908
4921
|
}
|
|
4909
4922
|
}
|
|
4910
|
-
var SingleLineStatements$0 = $TS($S($Q($S($
|
|
4923
|
+
var SingleLineStatements$0 = $TS($S($Q($S($S($E(_), $N(EOS)), Statement, SemicolonDelimiter)), $E($S($S($E(_), $N(EOS)), Statement, $E(SemicolonDelimiter)))), function($skip, $loc, $0, $1, $2) {
|
|
4911
4924
|
var stmts = $1;
|
|
4912
4925
|
var last = $2;
|
|
4913
4926
|
const children = [...stmts];
|
|
@@ -9383,7 +9396,12 @@ ${input.slice(result.pos)}
|
|
|
9383
9396
|
return result;
|
|
9384
9397
|
}
|
|
9385
9398
|
}
|
|
9386
|
-
var ExportVarDec$0 = $S(InsertVar, VariableDeclarationList)
|
|
9399
|
+
var ExportVarDec$0 = $TS($S(InsertVar, VariableDeclarationList), function($skip, $loc, $0, $1, $2) {
|
|
9400
|
+
return {
|
|
9401
|
+
...$2,
|
|
9402
|
+
children: [$1, ...$2.children]
|
|
9403
|
+
};
|
|
9404
|
+
});
|
|
9387
9405
|
function ExportVarDec(state) {
|
|
9388
9406
|
let eventData;
|
|
9389
9407
|
if (state.events) {
|
|
@@ -11206,6 +11224,30 @@ ${input.slice(result.pos)}
|
|
|
11206
11224
|
return result;
|
|
11207
11225
|
}
|
|
11208
11226
|
}
|
|
11227
|
+
var SimpleStatementDelimiter$0 = SemicolonDelimiter;
|
|
11228
|
+
var SimpleStatementDelimiter$1 = $Y(EOS);
|
|
11229
|
+
function SimpleStatementDelimiter(state) {
|
|
11230
|
+
let eventData;
|
|
11231
|
+
if (state.events) {
|
|
11232
|
+
const result = state.events.enter?.("SimpleStatementDelimiter", state);
|
|
11233
|
+
if (result) {
|
|
11234
|
+
if (result.cache)
|
|
11235
|
+
return result.cache;
|
|
11236
|
+
eventData = result.data;
|
|
11237
|
+
}
|
|
11238
|
+
}
|
|
11239
|
+
if (state.tokenize) {
|
|
11240
|
+
const result = $TOKEN("SimpleStatementDelimiter", state, SimpleStatementDelimiter$0(state) || SimpleStatementDelimiter$1(state));
|
|
11241
|
+
if (state.events)
|
|
11242
|
+
state.events.exit?.("SimpleStatementDelimiter", state, result, eventData);
|
|
11243
|
+
return result;
|
|
11244
|
+
} else {
|
|
11245
|
+
const result = SimpleStatementDelimiter$0(state) || SimpleStatementDelimiter$1(state);
|
|
11246
|
+
if (state.events)
|
|
11247
|
+
state.events.exit?.("SimpleStatementDelimiter", state, result, eventData);
|
|
11248
|
+
return result;
|
|
11249
|
+
}
|
|
11250
|
+
}
|
|
11209
11251
|
var StatementDelimiter$0 = SemicolonDelimiter;
|
|
11210
11252
|
var StatementDelimiter$1 = $S($Y($S(Samedent, $C($EXPECT($L92, fail, 'StatementDelimiter "("'), $EXPECT($L93, fail, 'StatementDelimiter "["'), $EXPECT($L94, fail, 'StatementDelimiter "`"'), $EXPECT($L54, fail, 'StatementDelimiter "+"'), $EXPECT($L55, fail, 'StatementDelimiter "-"'), $EXPECT($L50, fail, 'StatementDelimiter "*"'), $EXPECT($L51, fail, 'StatementDelimiter "/"'), ObjectLiteral))), InsertSemicolon);
|
|
11211
11253
|
var StatementDelimiter$2 = $Y(EOS);
|
|
@@ -15945,11 +15987,11 @@ ${input.slice(result.pos)}
|
|
|
15945
15987
|
return result;
|
|
15946
15988
|
}
|
|
15947
15989
|
}
|
|
15948
|
-
var CivetPrologue$0 = $T($S($EXPECT($R54, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(
|
|
15990
|
+
var CivetPrologue$0 = $T($S($EXPECT($R54, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(SimpleStatementDelimiter), $E(EOS)), function(value) {
|
|
15949
15991
|
var content = value[2];
|
|
15950
15992
|
return content;
|
|
15951
15993
|
});
|
|
15952
|
-
var CivetPrologue$1 = $T($S($EXPECT($R54, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(
|
|
15994
|
+
var CivetPrologue$1 = $T($S($EXPECT($R54, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(SimpleStatementDelimiter), $E(EOS)), function(value) {
|
|
15953
15995
|
var content = value[2];
|
|
15954
15996
|
return content;
|
|
15955
15997
|
});
|
|
@@ -16041,7 +16083,7 @@ ${input.slice(result.pos)}
|
|
|
16041
16083
|
return result;
|
|
16042
16084
|
}
|
|
16043
16085
|
}
|
|
16044
|
-
var UnknownPrologue$0 = $S($R$0($EXPECT($R54, fail, "UnknownPrologue /[\\t ]*/")), BasicStringLiteral, $TEXT(
|
|
16086
|
+
var UnknownPrologue$0 = $S($R$0($EXPECT($R54, fail, "UnknownPrologue /[\\t ]*/")), BasicStringLiteral, $TEXT(SimpleStatementDelimiter), EOS);
|
|
16045
16087
|
function UnknownPrologue(state) {
|
|
16046
16088
|
let eventData;
|
|
16047
16089
|
if (state.events) {
|
|
@@ -18103,9 +18145,6 @@ ${input.slice(result.pos)}
|
|
|
18103
18145
|
scopes.pop();
|
|
18104
18146
|
}
|
|
18105
18147
|
function createLetDecs(statements, scopes) {
|
|
18106
|
-
function hasDec(name) {
|
|
18107
|
-
return scopes.some((s) => s.has(name));
|
|
18108
|
-
}
|
|
18109
18148
|
function findVarDecs(statements2, decs) {
|
|
18110
18149
|
const declarationNames = gatherRecursive(
|
|
18111
18150
|
statements2,
|
|
@@ -18113,52 +18152,68 @@ ${input.slice(result.pos)}
|
|
|
18113
18152
|
).filter((node) => node.type === "Declaration").flatMap((node) => node.names);
|
|
18114
18153
|
return new Set(declarationNames);
|
|
18115
18154
|
}
|
|
18116
|
-
|
|
18117
|
-
|
|
18118
|
-
|
|
18119
|
-
|
|
18120
|
-
|
|
18121
|
-
|
|
18122
|
-
|
|
18155
|
+
let declaredIdentifiers = findVarDecs(statements);
|
|
18156
|
+
function hasDec(name) {
|
|
18157
|
+
return declaredIdentifiers.has(name) || scopes.some((s) => s.has(name));
|
|
18158
|
+
}
|
|
18159
|
+
function gatherBlockOrOther(statement) {
|
|
18160
|
+
return gatherNodes(statement, (s) => s.type === "BlockStatement" || s.type === "AssignmentExpression" || s.type === "Declaration").flatMap((node) => {
|
|
18161
|
+
if (node.type == "BlockStatement")
|
|
18162
|
+
return node.bare ? gatherBlockOrOther(node.expressions) : node;
|
|
18163
|
+
else if (node.children && node.children.length)
|
|
18164
|
+
return [...gatherBlockOrOther(node.children), node];
|
|
18165
|
+
else
|
|
18166
|
+
return [];
|
|
18167
|
+
});
|
|
18123
18168
|
}
|
|
18124
18169
|
let currentScope = /* @__PURE__ */ new Set();
|
|
18125
18170
|
scopes.push(currentScope);
|
|
18126
18171
|
const fnNodes = gatherNodes(statements, (s) => s.type === "FunctionExpression");
|
|
18127
18172
|
const forNodes = gatherNodes(statements, (s) => s.type === "ForStatement");
|
|
18128
|
-
|
|
18129
|
-
|
|
18130
|
-
|
|
18131
|
-
|
|
18132
|
-
|
|
18133
|
-
if (node.
|
|
18134
|
-
|
|
18135
|
-
|
|
18136
|
-
|
|
18137
|
-
|
|
18138
|
-
|
|
18139
|
-
|
|
18173
|
+
let targetStatements = [];
|
|
18174
|
+
for (const statement of statements) {
|
|
18175
|
+
const nodes = gatherBlockOrOther(statement);
|
|
18176
|
+
let undeclaredIdentifiers = [];
|
|
18177
|
+
for (const node of nodes) {
|
|
18178
|
+
if (node.type == "BlockStatement") {
|
|
18179
|
+
let block = node;
|
|
18180
|
+
let fnNode = fnNodes.find((fnNode2) => fnNode2.block === block);
|
|
18181
|
+
let forNode = forNodes.find((forNode2) => forNode2.block === block);
|
|
18182
|
+
if (fnNode != null) {
|
|
18183
|
+
scopes.push(new Set(fnNode.parameters.names));
|
|
18184
|
+
createLetDecs(block.expressions, scopes);
|
|
18185
|
+
scopes.pop();
|
|
18186
|
+
} else if (forNode != null) {
|
|
18187
|
+
scopes.push(new Set(forNode.declaration.names));
|
|
18188
|
+
createLetDecs(block.expressions, scopes);
|
|
18189
|
+
scopes.pop();
|
|
18190
|
+
} else
|
|
18191
|
+
createLetDecs(block.expressions, scopes);
|
|
18192
|
+
continue;
|
|
18193
|
+
}
|
|
18194
|
+
if (node.names == null)
|
|
18195
|
+
continue;
|
|
18196
|
+
let names = node.names.filter((name) => !hasDec(name));
|
|
18197
|
+
if (node.type == "AssignmentExpression")
|
|
18198
|
+
undeclaredIdentifiers.push(...names);
|
|
18199
|
+
names.forEach((name) => currentScope.add(name));
|
|
18200
|
+
}
|
|
18201
|
+
if (undeclaredIdentifiers.length > 0) {
|
|
18202
|
+
let indent = statement[0];
|
|
18203
|
+
let firstIdentifier = gatherNodes(statement[1], (node) => node.type == "Identifier")[0];
|
|
18204
|
+
if (undeclaredIdentifiers.length == 1 && statement[1].type == "AssignmentExpression" && statement[1].names.length == 1 && statement[1].names[0] == undeclaredIdentifiers[0] && firstIdentifier && firstIdentifier.names == undeclaredIdentifiers[0] && gatherNodes(statement[1], (node) => node.type === "ObjectBindingPattern").length == 0)
|
|
18205
|
+
statement[1].children.unshift(["let "]);
|
|
18206
|
+
else {
|
|
18207
|
+
let tail = "\n";
|
|
18208
|
+
if (gatherNodes(indent, (node) => node.token && node.token.endsWith("\n")).length > 0)
|
|
18209
|
+
tail = void 0;
|
|
18210
|
+
targetStatements.push([indent, "let ", undeclaredIdentifiers.join(", "), tail]);
|
|
18140
18211
|
}
|
|
18141
|
-
} else if (node.type == "Declaration") {
|
|
18142
|
-
if (node.children && node.children.length)
|
|
18143
|
-
createLetDecs(node.children, scopes);
|
|
18144
|
-
node.names.forEach((name) => currentScope.add(name));
|
|
18145
|
-
} else {
|
|
18146
|
-
let block = node;
|
|
18147
|
-
let fnNode = fnNodes.find((fnNode2) => fnNode2.block === block);
|
|
18148
|
-
let forNode = forNodes.find((forNode2) => forNode2.block === block);
|
|
18149
|
-
if (fnNode != null) {
|
|
18150
|
-
scopes.push(new Set(fnNode.parameters.names));
|
|
18151
|
-
createLetDecs(block.expressions, scopes);
|
|
18152
|
-
scopes.pop();
|
|
18153
|
-
} else if (forNode != null) {
|
|
18154
|
-
scopes.push(new Set(forNode.declaration.names));
|
|
18155
|
-
createLetDecs(block.expressions, scopes);
|
|
18156
|
-
scopes.pop();
|
|
18157
|
-
} else
|
|
18158
|
-
createLetDecs(block.expressions, scopes);
|
|
18159
18212
|
}
|
|
18213
|
+
targetStatements.push(statement);
|
|
18160
18214
|
}
|
|
18161
18215
|
scopes.pop();
|
|
18216
|
+
statements.splice(0, statements.length, targetStatements);
|
|
18162
18217
|
}
|
|
18163
18218
|
function gatherBindingCode(statements, opts) {
|
|
18164
18219
|
const thisAssignments = [];
|
|
@@ -18876,7 +18931,7 @@ var uncacheable;
|
|
|
18876
18931
|
({ parse } = import_parser.default);
|
|
18877
18932
|
({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
|
|
18878
18933
|
defaultOptions = {};
|
|
18879
|
-
uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationSuppressed", "ExtendedExpression", "FatArrowBody", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedObject", "NestedPropertyDefinitions", "NonSuppressedTrailingMemberExpressions", "ObjectLiteral", "PopIndent", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "Samedent", "ShortCircuitExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuppressIndentedApplication", "SuppressTrailingMemberProperty", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
|
|
18934
|
+
uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationSuppressed", "ExtendedExpression", "FatArrowBody", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedObject", "NestedPropertyDefinitions", "NonSuppressedTrailingMemberExpressions", "ObjectLiteral", "PopIndent", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuppressIndentedApplication", "SuppressTrailingMemberProperty", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
|
|
18880
18935
|
var compile = function(src, options = defaultOptions) {
|
|
18881
18936
|
var ast, code, events, filename, sm, srcMapJSON;
|
|
18882
18937
|
filename = options.filename || "unknown";
|
package/dist/main.mjs
CHANGED
|
@@ -426,6 +426,7 @@ ${input.slice(result.pos)}
|
|
|
426
426
|
Program,
|
|
427
427
|
TopLevelStatement,
|
|
428
428
|
ExtendedExpression,
|
|
429
|
+
SingleLineExtendedExpression,
|
|
429
430
|
NonPipelineExtendedExpression,
|
|
430
431
|
NonAssignmentExtendedExpression,
|
|
431
432
|
ExpressionizedStatement,
|
|
@@ -738,6 +739,7 @@ ${input.slice(result.pos)}
|
|
|
738
739
|
__,
|
|
739
740
|
Whitespace,
|
|
740
741
|
ExpressionDelimiter,
|
|
742
|
+
SimpleStatementDelimiter,
|
|
741
743
|
StatementDelimiter,
|
|
742
744
|
SemicolonDelimiter,
|
|
743
745
|
NonIdContinue,
|
|
@@ -1267,6 +1269,30 @@ ${input.slice(result.pos)}
|
|
|
1267
1269
|
return result;
|
|
1268
1270
|
}
|
|
1269
1271
|
}
|
|
1272
|
+
var SingleLineExtendedExpression$0 = NonAssignmentExtendedExpression;
|
|
1273
|
+
var SingleLineExtendedExpression$1 = SingleLineAssignmentExpression;
|
|
1274
|
+
function SingleLineExtendedExpression(state) {
|
|
1275
|
+
let eventData;
|
|
1276
|
+
if (state.events) {
|
|
1277
|
+
const result = state.events.enter?.("SingleLineExtendedExpression", state);
|
|
1278
|
+
if (result) {
|
|
1279
|
+
if (result.cache)
|
|
1280
|
+
return result.cache;
|
|
1281
|
+
eventData = result.data;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
if (state.tokenize) {
|
|
1285
|
+
const result = $TOKEN("SingleLineExtendedExpression", state, SingleLineExtendedExpression$0(state) || SingleLineExtendedExpression$1(state));
|
|
1286
|
+
if (state.events)
|
|
1287
|
+
state.events.exit?.("SingleLineExtendedExpression", state, result, eventData);
|
|
1288
|
+
return result;
|
|
1289
|
+
} else {
|
|
1290
|
+
const result = SingleLineExtendedExpression$0(state) || SingleLineExtendedExpression$1(state);
|
|
1291
|
+
if (state.events)
|
|
1292
|
+
state.events.exit?.("SingleLineExtendedExpression", state, result, eventData);
|
|
1293
|
+
return result;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1270
1296
|
var NonPipelineExtendedExpression$0 = NonAssignmentExtendedExpression;
|
|
1271
1297
|
var NonPipelineExtendedExpression$1 = NonPipelineAssignmentExpression;
|
|
1272
1298
|
function NonPipelineExtendedExpression(state) {
|
|
@@ -1964,20 +1990,7 @@ ${input.slice(result.pos)}
|
|
|
1964
1990
|
}
|
|
1965
1991
|
}
|
|
1966
1992
|
var AssignmentExpression$0 = PipelineExpression;
|
|
1967
|
-
var AssignmentExpression$1 =
|
|
1968
|
-
var ws = $1;
|
|
1969
|
-
var tail = $2;
|
|
1970
|
-
if (ws.length) {
|
|
1971
|
-
if (tail.children && tail.type !== "IterationExpression") {
|
|
1972
|
-
return {
|
|
1973
|
-
...tail,
|
|
1974
|
-
children: [...ws, ...tail.children]
|
|
1975
|
-
};
|
|
1976
|
-
}
|
|
1977
|
-
return $0;
|
|
1978
|
-
}
|
|
1979
|
-
return tail;
|
|
1980
|
-
});
|
|
1993
|
+
var AssignmentExpression$1 = SingleLineAssignmentExpression;
|
|
1981
1994
|
var AssignmentExpression$2 = $S(__, AssignmentExpressionTail);
|
|
1982
1995
|
function AssignmentExpression(state) {
|
|
1983
1996
|
let eventData;
|
|
@@ -4905,7 +4918,7 @@ ${input.slice(result.pos)}
|
|
|
4905
4918
|
return result;
|
|
4906
4919
|
}
|
|
4907
4920
|
}
|
|
4908
|
-
var SingleLineStatements$0 = $TS($S($Q($S($
|
|
4921
|
+
var SingleLineStatements$0 = $TS($S($Q($S($S($E(_), $N(EOS)), Statement, SemicolonDelimiter)), $E($S($S($E(_), $N(EOS)), Statement, $E(SemicolonDelimiter)))), function($skip, $loc, $0, $1, $2) {
|
|
4909
4922
|
var stmts = $1;
|
|
4910
4923
|
var last = $2;
|
|
4911
4924
|
const children = [...stmts];
|
|
@@ -9381,7 +9394,12 @@ ${input.slice(result.pos)}
|
|
|
9381
9394
|
return result;
|
|
9382
9395
|
}
|
|
9383
9396
|
}
|
|
9384
|
-
var ExportVarDec$0 = $S(InsertVar, VariableDeclarationList)
|
|
9397
|
+
var ExportVarDec$0 = $TS($S(InsertVar, VariableDeclarationList), function($skip, $loc, $0, $1, $2) {
|
|
9398
|
+
return {
|
|
9399
|
+
...$2,
|
|
9400
|
+
children: [$1, ...$2.children]
|
|
9401
|
+
};
|
|
9402
|
+
});
|
|
9385
9403
|
function ExportVarDec(state) {
|
|
9386
9404
|
let eventData;
|
|
9387
9405
|
if (state.events) {
|
|
@@ -11204,6 +11222,30 @@ ${input.slice(result.pos)}
|
|
|
11204
11222
|
return result;
|
|
11205
11223
|
}
|
|
11206
11224
|
}
|
|
11225
|
+
var SimpleStatementDelimiter$0 = SemicolonDelimiter;
|
|
11226
|
+
var SimpleStatementDelimiter$1 = $Y(EOS);
|
|
11227
|
+
function SimpleStatementDelimiter(state) {
|
|
11228
|
+
let eventData;
|
|
11229
|
+
if (state.events) {
|
|
11230
|
+
const result = state.events.enter?.("SimpleStatementDelimiter", state);
|
|
11231
|
+
if (result) {
|
|
11232
|
+
if (result.cache)
|
|
11233
|
+
return result.cache;
|
|
11234
|
+
eventData = result.data;
|
|
11235
|
+
}
|
|
11236
|
+
}
|
|
11237
|
+
if (state.tokenize) {
|
|
11238
|
+
const result = $TOKEN("SimpleStatementDelimiter", state, SimpleStatementDelimiter$0(state) || SimpleStatementDelimiter$1(state));
|
|
11239
|
+
if (state.events)
|
|
11240
|
+
state.events.exit?.("SimpleStatementDelimiter", state, result, eventData);
|
|
11241
|
+
return result;
|
|
11242
|
+
} else {
|
|
11243
|
+
const result = SimpleStatementDelimiter$0(state) || SimpleStatementDelimiter$1(state);
|
|
11244
|
+
if (state.events)
|
|
11245
|
+
state.events.exit?.("SimpleStatementDelimiter", state, result, eventData);
|
|
11246
|
+
return result;
|
|
11247
|
+
}
|
|
11248
|
+
}
|
|
11207
11249
|
var StatementDelimiter$0 = SemicolonDelimiter;
|
|
11208
11250
|
var StatementDelimiter$1 = $S($Y($S(Samedent, $C($EXPECT($L92, fail, 'StatementDelimiter "("'), $EXPECT($L93, fail, 'StatementDelimiter "["'), $EXPECT($L94, fail, 'StatementDelimiter "`"'), $EXPECT($L54, fail, 'StatementDelimiter "+"'), $EXPECT($L55, fail, 'StatementDelimiter "-"'), $EXPECT($L50, fail, 'StatementDelimiter "*"'), $EXPECT($L51, fail, 'StatementDelimiter "/"'), ObjectLiteral))), InsertSemicolon);
|
|
11209
11251
|
var StatementDelimiter$2 = $Y(EOS);
|
|
@@ -15943,11 +15985,11 @@ ${input.slice(result.pos)}
|
|
|
15943
15985
|
return result;
|
|
15944
15986
|
}
|
|
15945
15987
|
}
|
|
15946
|
-
var CivetPrologue$0 = $T($S($EXPECT($R54, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(
|
|
15988
|
+
var CivetPrologue$0 = $T($S($EXPECT($R54, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(SimpleStatementDelimiter), $E(EOS)), function(value) {
|
|
15947
15989
|
var content = value[2];
|
|
15948
15990
|
return content;
|
|
15949
15991
|
});
|
|
15950
|
-
var CivetPrologue$1 = $T($S($EXPECT($R54, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(
|
|
15992
|
+
var CivetPrologue$1 = $T($S($EXPECT($R54, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(SimpleStatementDelimiter), $E(EOS)), function(value) {
|
|
15951
15993
|
var content = value[2];
|
|
15952
15994
|
return content;
|
|
15953
15995
|
});
|
|
@@ -16039,7 +16081,7 @@ ${input.slice(result.pos)}
|
|
|
16039
16081
|
return result;
|
|
16040
16082
|
}
|
|
16041
16083
|
}
|
|
16042
|
-
var UnknownPrologue$0 = $S($R$0($EXPECT($R54, fail, "UnknownPrologue /[\\t ]*/")), BasicStringLiteral, $TEXT(
|
|
16084
|
+
var UnknownPrologue$0 = $S($R$0($EXPECT($R54, fail, "UnknownPrologue /[\\t ]*/")), BasicStringLiteral, $TEXT(SimpleStatementDelimiter), EOS);
|
|
16043
16085
|
function UnknownPrologue(state) {
|
|
16044
16086
|
let eventData;
|
|
16045
16087
|
if (state.events) {
|
|
@@ -18101,9 +18143,6 @@ ${input.slice(result.pos)}
|
|
|
18101
18143
|
scopes.pop();
|
|
18102
18144
|
}
|
|
18103
18145
|
function createLetDecs(statements, scopes) {
|
|
18104
|
-
function hasDec(name) {
|
|
18105
|
-
return scopes.some((s) => s.has(name));
|
|
18106
|
-
}
|
|
18107
18146
|
function findVarDecs(statements2, decs) {
|
|
18108
18147
|
const declarationNames = gatherRecursive(
|
|
18109
18148
|
statements2,
|
|
@@ -18111,52 +18150,68 @@ ${input.slice(result.pos)}
|
|
|
18111
18150
|
).filter((node) => node.type === "Declaration").flatMap((node) => node.names);
|
|
18112
18151
|
return new Set(declarationNames);
|
|
18113
18152
|
}
|
|
18114
|
-
|
|
18115
|
-
|
|
18116
|
-
|
|
18117
|
-
|
|
18118
|
-
|
|
18119
|
-
|
|
18120
|
-
|
|
18153
|
+
let declaredIdentifiers = findVarDecs(statements);
|
|
18154
|
+
function hasDec(name) {
|
|
18155
|
+
return declaredIdentifiers.has(name) || scopes.some((s) => s.has(name));
|
|
18156
|
+
}
|
|
18157
|
+
function gatherBlockOrOther(statement) {
|
|
18158
|
+
return gatherNodes(statement, (s) => s.type === "BlockStatement" || s.type === "AssignmentExpression" || s.type === "Declaration").flatMap((node) => {
|
|
18159
|
+
if (node.type == "BlockStatement")
|
|
18160
|
+
return node.bare ? gatherBlockOrOther(node.expressions) : node;
|
|
18161
|
+
else if (node.children && node.children.length)
|
|
18162
|
+
return [...gatherBlockOrOther(node.children), node];
|
|
18163
|
+
else
|
|
18164
|
+
return [];
|
|
18165
|
+
});
|
|
18121
18166
|
}
|
|
18122
18167
|
let currentScope = /* @__PURE__ */ new Set();
|
|
18123
18168
|
scopes.push(currentScope);
|
|
18124
18169
|
const fnNodes = gatherNodes(statements, (s) => s.type === "FunctionExpression");
|
|
18125
18170
|
const forNodes = gatherNodes(statements, (s) => s.type === "ForStatement");
|
|
18126
|
-
|
|
18127
|
-
|
|
18128
|
-
|
|
18129
|
-
|
|
18130
|
-
|
|
18131
|
-
if (node.
|
|
18132
|
-
|
|
18133
|
-
|
|
18134
|
-
|
|
18135
|
-
|
|
18136
|
-
|
|
18137
|
-
|
|
18171
|
+
let targetStatements = [];
|
|
18172
|
+
for (const statement of statements) {
|
|
18173
|
+
const nodes = gatherBlockOrOther(statement);
|
|
18174
|
+
let undeclaredIdentifiers = [];
|
|
18175
|
+
for (const node of nodes) {
|
|
18176
|
+
if (node.type == "BlockStatement") {
|
|
18177
|
+
let block = node;
|
|
18178
|
+
let fnNode = fnNodes.find((fnNode2) => fnNode2.block === block);
|
|
18179
|
+
let forNode = forNodes.find((forNode2) => forNode2.block === block);
|
|
18180
|
+
if (fnNode != null) {
|
|
18181
|
+
scopes.push(new Set(fnNode.parameters.names));
|
|
18182
|
+
createLetDecs(block.expressions, scopes);
|
|
18183
|
+
scopes.pop();
|
|
18184
|
+
} else if (forNode != null) {
|
|
18185
|
+
scopes.push(new Set(forNode.declaration.names));
|
|
18186
|
+
createLetDecs(block.expressions, scopes);
|
|
18187
|
+
scopes.pop();
|
|
18188
|
+
} else
|
|
18189
|
+
createLetDecs(block.expressions, scopes);
|
|
18190
|
+
continue;
|
|
18191
|
+
}
|
|
18192
|
+
if (node.names == null)
|
|
18193
|
+
continue;
|
|
18194
|
+
let names = node.names.filter((name) => !hasDec(name));
|
|
18195
|
+
if (node.type == "AssignmentExpression")
|
|
18196
|
+
undeclaredIdentifiers.push(...names);
|
|
18197
|
+
names.forEach((name) => currentScope.add(name));
|
|
18198
|
+
}
|
|
18199
|
+
if (undeclaredIdentifiers.length > 0) {
|
|
18200
|
+
let indent = statement[0];
|
|
18201
|
+
let firstIdentifier = gatherNodes(statement[1], (node) => node.type == "Identifier")[0];
|
|
18202
|
+
if (undeclaredIdentifiers.length == 1 && statement[1].type == "AssignmentExpression" && statement[1].names.length == 1 && statement[1].names[0] == undeclaredIdentifiers[0] && firstIdentifier && firstIdentifier.names == undeclaredIdentifiers[0] && gatherNodes(statement[1], (node) => node.type === "ObjectBindingPattern").length == 0)
|
|
18203
|
+
statement[1].children.unshift(["let "]);
|
|
18204
|
+
else {
|
|
18205
|
+
let tail = "\n";
|
|
18206
|
+
if (gatherNodes(indent, (node) => node.token && node.token.endsWith("\n")).length > 0)
|
|
18207
|
+
tail = void 0;
|
|
18208
|
+
targetStatements.push([indent, "let ", undeclaredIdentifiers.join(", "), tail]);
|
|
18138
18209
|
}
|
|
18139
|
-
} else if (node.type == "Declaration") {
|
|
18140
|
-
if (node.children && node.children.length)
|
|
18141
|
-
createLetDecs(node.children, scopes);
|
|
18142
|
-
node.names.forEach((name) => currentScope.add(name));
|
|
18143
|
-
} else {
|
|
18144
|
-
let block = node;
|
|
18145
|
-
let fnNode = fnNodes.find((fnNode2) => fnNode2.block === block);
|
|
18146
|
-
let forNode = forNodes.find((forNode2) => forNode2.block === block);
|
|
18147
|
-
if (fnNode != null) {
|
|
18148
|
-
scopes.push(new Set(fnNode.parameters.names));
|
|
18149
|
-
createLetDecs(block.expressions, scopes);
|
|
18150
|
-
scopes.pop();
|
|
18151
|
-
} else if (forNode != null) {
|
|
18152
|
-
scopes.push(new Set(forNode.declaration.names));
|
|
18153
|
-
createLetDecs(block.expressions, scopes);
|
|
18154
|
-
scopes.pop();
|
|
18155
|
-
} else
|
|
18156
|
-
createLetDecs(block.expressions, scopes);
|
|
18157
18210
|
}
|
|
18211
|
+
targetStatements.push(statement);
|
|
18158
18212
|
}
|
|
18159
18213
|
scopes.pop();
|
|
18214
|
+
statements.splice(0, statements.length, targetStatements);
|
|
18160
18215
|
}
|
|
18161
18216
|
function gatherBindingCode(statements, opts) {
|
|
18162
18217
|
const thisAssignments = [];
|
|
@@ -18864,7 +18919,7 @@ var uncacheable;
|
|
|
18864
18919
|
({ parse } = import_parser.default);
|
|
18865
18920
|
({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
|
|
18866
18921
|
defaultOptions = {};
|
|
18867
|
-
uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationSuppressed", "ExtendedExpression", "FatArrowBody", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedObject", "NestedPropertyDefinitions", "NonSuppressedTrailingMemberExpressions", "ObjectLiteral", "PopIndent", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "Samedent", "ShortCircuitExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuppressIndentedApplication", "SuppressTrailingMemberProperty", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
|
|
18922
|
+
uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationSuppressed", "ExtendedExpression", "FatArrowBody", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedObject", "NestedPropertyDefinitions", "NonSuppressedTrailingMemberExpressions", "ObjectLiteral", "PopIndent", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuppressIndentedApplication", "SuppressTrailingMemberProperty", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
|
|
18868
18923
|
var compile = function(src, options = defaultOptions) {
|
|
18869
18924
|
var ast, code, events, filename, sm, srcMapJSON;
|
|
18870
18925
|
filename = options.filename || "unknown";
|