@danielx/civet 0.5.19 → 0.5.21
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/README.md +25 -1
- package/dist/browser.js +79 -9
- package/dist/main.js +79 -9
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -140,6 +140,8 @@ Things Changed from CoffeeScript
|
|
|
140
140
|
- `x?.y` now compiles to `x?.y` rather than the `if typeof x !== 'undefined' && x !== null` if check
|
|
141
141
|
- Existential `x?` → `(x != null)` no longer checks for undeclared variables.
|
|
142
142
|
- `x?()` → `x?.()` instead of `if (typeof x === 'function') { x() }`
|
|
143
|
+
- Functions don't implicitly return the last value if there's a semicolon
|
|
144
|
+
at the end: `-> x` returns `x` but `-> x;` does not
|
|
143
145
|
- Backtick embedded JS has been replaced with JS template literals.
|
|
144
146
|
- No longer allowing multiple postfix `if/unless` on the same line (use `&&` or `and` to combine conditions).
|
|
145
147
|
- `#{}` interpolation in `""` strings only when `"civet coffeeCompat"` or `"civet coffeeInterpolation"`
|
|
@@ -193,6 +195,9 @@ Things Added that CoffeeScript didn't
|
|
|
193
195
|
- Private identifiers `#id`
|
|
194
196
|
- Convenience for ES6+ Features
|
|
195
197
|
- Const assignment shorthand: `a := b` → `const a = b`, `{a, b} := c` → `const {a, b} = c`
|
|
198
|
+
- Let assignment shorthand (experimental): `a .= b` or `a ::= b` → `let a = b`
|
|
199
|
+
- Typed versions of above: `a: number .= 5` → `let a: number = 5`
|
|
200
|
+
(but note that `a: number = 5` is the object literal `{a: (number = 5)}`).
|
|
196
201
|
- `@#id` → `this.#id` shorthand for private identifiers
|
|
197
202
|
- `import` shorthand: `x from ./x` → `import x from "./x"`
|
|
198
203
|
- Dynamic `import` shorthand: `import './x'` not at top level
|
|
@@ -209,6 +214,13 @@ Things Added that CoffeeScript didn't
|
|
|
209
214
|
- Function call: `x.map &.callback a, b` → `x.map($ => $.callback(a, b))`
|
|
210
215
|
- Unary operators: `x.map !!&` → `x.map($ => !!$)`
|
|
211
216
|
- Binary operators: `x.map &+1` → `x.map($ => $+1)`
|
|
217
|
+
- Pipe operator (based on [F# pipes](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/symbol-and-operator-reference/#function-symbols-and-operators), [Hack pipes](https://docs.hhvm.com/hack/expressions-and-operators/pipe) and the [TC39 proposal](https://github.com/tc39/proposal-pipeline-operator))
|
|
218
|
+
- `data |> Object.keys |> console.log` equivalent to
|
|
219
|
+
`console.log(Object.keys(data))`
|
|
220
|
+
- Use single-argument arrow functions or `&` shorthand
|
|
221
|
+
to specify how to use left-hand side
|
|
222
|
+
- `|> await`, `|> yield`, and `|> return` (at end)
|
|
223
|
+
for wrapping left-hand side with that operation
|
|
212
224
|
- Flagging shorthand [from LiveScript](https://livescript.net/#literals) `{+debug, -live}` → `{debug: true, live: false}`
|
|
213
225
|
- JSX enhancements (inspired by [solid-dsl discussions](https://github.com/solidjs-community/solid-dsl/discussions)):
|
|
214
226
|
- Indentation: instead of explicitly closing `<tag>`s or `<>`s,
|
|
@@ -252,7 +264,9 @@ Things Added that CoffeeScript didn't
|
|
|
252
264
|
Things Changed from ES6
|
|
253
265
|
---
|
|
254
266
|
|
|
255
|
-
- Implicit returns
|
|
267
|
+
- Implicit returns, even for multi-statement functions
|
|
268
|
+
(avoid by adding a trailing `;`, an explicit `return`, or
|
|
269
|
+
via the directive `"civet -implicitReturns"`)
|
|
256
270
|
- Disallow no parens on single argument arrow function. `x => ...` must become `(x) => ...`
|
|
257
271
|
The reasoning is `x -> ...` => `x(function() ...)` in CoffeeScript and having `->` and `=>`
|
|
258
272
|
behave more differently than they already do is bad. Passing an anonymous function to an
|
|
@@ -298,6 +312,16 @@ You can use these with `"civet coffeeCompat"` to opt in to all or use them bit b
|
|
|
298
312
|
Another possibility is to slowly remove them to provide a way to migrate files a little at a time `"civet coffeeCompat -coffeeBooleans -coffeeComment -coffeeEq"`.
|
|
299
313
|
Both camel case and hyphens work when specifying options `"civet coffee-compat"`. More options will be added over time until 97+% compatibility is achieved.
|
|
300
314
|
|
|
315
|
+
ECMAScript Compatibility
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
You can also specify `"civet"` prologue directives to increase
|
|
319
|
+
compatibility with ECMAScript/TypeScript:
|
|
320
|
+
|
|
321
|
+
| Configuration | What it enables |
|
|
322
|
+
|---------------------|---------------------------------------|
|
|
323
|
+
| -implicit-returns | turn off implicit return of last value in functions |
|
|
324
|
+
|
|
301
325
|
Other Options
|
|
302
326
|
---
|
|
303
327
|
|
package/dist/browser.js
CHANGED
|
@@ -441,6 +441,7 @@ ${input.slice(result.pos)}
|
|
|
441
441
|
ParenthesizedExpression,
|
|
442
442
|
ClassDeclaration,
|
|
443
443
|
ClassExpression,
|
|
444
|
+
ClassBinding,
|
|
444
445
|
ClassHeritage,
|
|
445
446
|
ExtendsClause,
|
|
446
447
|
ExtendsToken,
|
|
@@ -692,6 +693,7 @@ ${input.slice(result.pos)}
|
|
|
692
693
|
Whitespace,
|
|
693
694
|
ExpressionDelimiter,
|
|
694
695
|
StatementDelimiter,
|
|
696
|
+
SemicolonDelimiter,
|
|
695
697
|
NonIdContinue,
|
|
696
698
|
Loc,
|
|
697
699
|
Abstract,
|
|
@@ -2104,7 +2106,8 @@ ${input.slice(result.pos)}
|
|
|
2104
2106
|
}
|
|
2105
2107
|
var PipelineTailItem$0 = Await;
|
|
2106
2108
|
var PipelineTailItem$1 = Yield;
|
|
2107
|
-
var PipelineTailItem$2 =
|
|
2109
|
+
var PipelineTailItem$2 = Return;
|
|
2110
|
+
var PipelineTailItem$3 = PipelineHeadItem;
|
|
2108
2111
|
function PipelineTailItem(state) {
|
|
2109
2112
|
if (state.events) {
|
|
2110
2113
|
const result = state.events.enter?.("PipelineTailItem", state);
|
|
@@ -2112,12 +2115,12 @@ ${input.slice(result.pos)}
|
|
|
2112
2115
|
return result.cache;
|
|
2113
2116
|
}
|
|
2114
2117
|
if (state.tokenize) {
|
|
2115
|
-
const result = $TOKEN("PipelineTailItem", state, PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state));
|
|
2118
|
+
const result = $TOKEN("PipelineTailItem", state, PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state));
|
|
2116
2119
|
if (state.events)
|
|
2117
2120
|
state.events.exit?.("PipelineTailItem", state, result);
|
|
2118
2121
|
return result;
|
|
2119
2122
|
} else {
|
|
2120
|
-
const result = PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state);
|
|
2123
|
+
const result = PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state);
|
|
2121
2124
|
if (state.events)
|
|
2122
2125
|
state.events.exit?.("PipelineTailItem", state, result);
|
|
2123
2126
|
return result;
|
|
@@ -2202,7 +2205,7 @@ ${input.slice(result.pos)}
|
|
|
2202
2205
|
return result;
|
|
2203
2206
|
}
|
|
2204
2207
|
}
|
|
2205
|
-
var ClassExpression$0 = $TS($S($E(Decorators), $E($S(Abstract, __)), Class, $E(
|
|
2208
|
+
var ClassExpression$0 = $TS($S($E(Decorators), $E($S(Abstract, __)), Class, $E(ClassBinding), $E(ClassHeritage), ClassBody), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
2206
2209
|
return $0;
|
|
2207
2210
|
});
|
|
2208
2211
|
function ClassExpression(state) {
|
|
@@ -2223,6 +2226,27 @@ ${input.slice(result.pos)}
|
|
|
2223
2226
|
return result;
|
|
2224
2227
|
}
|
|
2225
2228
|
}
|
|
2229
|
+
var ClassBinding$0 = $T($S($N(EOS), BindingIdentifier, $E(TypeParameters)), function(value) {
|
|
2230
|
+
return [value[1], value[2]];
|
|
2231
|
+
});
|
|
2232
|
+
function ClassBinding(state) {
|
|
2233
|
+
if (state.events) {
|
|
2234
|
+
const result = state.events.enter?.("ClassBinding", state);
|
|
2235
|
+
if (result)
|
|
2236
|
+
return result.cache;
|
|
2237
|
+
}
|
|
2238
|
+
if (state.tokenize) {
|
|
2239
|
+
const result = $TOKEN("ClassBinding", state, ClassBinding$0(state));
|
|
2240
|
+
if (state.events)
|
|
2241
|
+
state.events.exit?.("ClassBinding", state, result);
|
|
2242
|
+
return result;
|
|
2243
|
+
} else {
|
|
2244
|
+
const result = ClassBinding$0(state);
|
|
2245
|
+
if (state.events)
|
|
2246
|
+
state.events.exit?.("ClassBinding", state, result);
|
|
2247
|
+
return result;
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2226
2250
|
var ClassHeritage$0 = $S(ExtendsClause, $E(ImplementsClause));
|
|
2227
2251
|
var ClassHeritage$1 = ImplementsClause;
|
|
2228
2252
|
function ClassHeritage(state) {
|
|
@@ -4065,7 +4089,7 @@ ${input.slice(result.pos)}
|
|
|
4065
4089
|
return result;
|
|
4066
4090
|
}
|
|
4067
4091
|
}
|
|
4068
|
-
var SingleLineStatements$0 = $TS($S($S($Q(TrailingComment), Statement), $Q($S(
|
|
4092
|
+
var SingleLineStatements$0 = $TS($S($S($Q(TrailingComment), Statement), $Q($S(SemicolonDelimiter, $E(Statement)))), function($skip, $loc, $0, $1, $2) {
|
|
4069
4093
|
var first = $1;
|
|
4070
4094
|
var rest = $2;
|
|
4071
4095
|
if (rest.length) {
|
|
@@ -5301,7 +5325,7 @@ ${input.slice(result.pos)}
|
|
|
5301
5325
|
ts: true
|
|
5302
5326
|
};
|
|
5303
5327
|
});
|
|
5304
|
-
var MethodDefinition$1 = $TS($S(MethodSignature,
|
|
5328
|
+
var MethodDefinition$1 = $TS($S(MethodSignature, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2) {
|
|
5305
5329
|
var signature = $1;
|
|
5306
5330
|
var block = $2;
|
|
5307
5331
|
return {
|
|
@@ -9256,7 +9280,7 @@ ${input.slice(result.pos)}
|
|
|
9256
9280
|
return result;
|
|
9257
9281
|
}
|
|
9258
9282
|
}
|
|
9259
|
-
var StatementDelimiter$0 =
|
|
9283
|
+
var StatementDelimiter$0 = SemicolonDelimiter;
|
|
9260
9284
|
var StatementDelimiter$1 = $Y(EOS);
|
|
9261
9285
|
function StatementDelimiter(state) {
|
|
9262
9286
|
if (state.events) {
|
|
@@ -9276,6 +9300,30 @@ ${input.slice(result.pos)}
|
|
|
9276
9300
|
return result;
|
|
9277
9301
|
}
|
|
9278
9302
|
}
|
|
9303
|
+
var SemicolonDelimiter$0 = $TS($S($Q(TrailingComment), Semicolon, $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3) {
|
|
9304
|
+
return {
|
|
9305
|
+
type: "SemicolonDelimiter",
|
|
9306
|
+
children: $0
|
|
9307
|
+
};
|
|
9308
|
+
});
|
|
9309
|
+
function SemicolonDelimiter(state) {
|
|
9310
|
+
if (state.events) {
|
|
9311
|
+
const result = state.events.enter?.("SemicolonDelimiter", state);
|
|
9312
|
+
if (result)
|
|
9313
|
+
return result.cache;
|
|
9314
|
+
}
|
|
9315
|
+
if (state.tokenize) {
|
|
9316
|
+
const result = $TOKEN("SemicolonDelimiter", state, SemicolonDelimiter$0(state));
|
|
9317
|
+
if (state.events)
|
|
9318
|
+
state.events.exit?.("SemicolonDelimiter", state, result);
|
|
9319
|
+
return result;
|
|
9320
|
+
} else {
|
|
9321
|
+
const result = SemicolonDelimiter$0(state);
|
|
9322
|
+
if (state.events)
|
|
9323
|
+
state.events.exit?.("SemicolonDelimiter", state, result);
|
|
9324
|
+
return result;
|
|
9325
|
+
}
|
|
9326
|
+
}
|
|
9279
9327
|
var NonIdContinue$0 = $R$0($EXPECT($R43, fail, "NonIdContinue /(?!\\p{ID_Continue})/"));
|
|
9280
9328
|
function NonIdContinue(state) {
|
|
9281
9329
|
if (state.events) {
|
|
@@ -11155,7 +11203,23 @@ ${input.slice(result.pos)}
|
|
|
11155
11203
|
if (stringPart) {
|
|
11156
11204
|
exprs.unshift(JSON.stringify(stringPart), ", ");
|
|
11157
11205
|
}
|
|
11158
|
-
|
|
11206
|
+
if (exprs.length === 1) {
|
|
11207
|
+
let root = exprs[0];
|
|
11208
|
+
while (root.length && module.isWhitespaceOrEmpty(root[root.length - 1])) {
|
|
11209
|
+
root = root.slice(0, -1);
|
|
11210
|
+
}
|
|
11211
|
+
while (root?.length === 1)
|
|
11212
|
+
root = root[0];
|
|
11213
|
+
if (root?.children)
|
|
11214
|
+
root = root.children;
|
|
11215
|
+
if (root?.[0]?.token === "`") {
|
|
11216
|
+
classValue = ["{", ...exprs, "}"];
|
|
11217
|
+
} else {
|
|
11218
|
+
classValue = ["{(", ...exprs, ') || ""}'];
|
|
11219
|
+
}
|
|
11220
|
+
} else {
|
|
11221
|
+
classValue = ["{[", ...exprs, '].filter(Boolean).join(" ")}'];
|
|
11222
|
+
}
|
|
11159
11223
|
} else {
|
|
11160
11224
|
classValue = JSON.stringify(stringPart);
|
|
11161
11225
|
}
|
|
@@ -13987,6 +14051,8 @@ ${input.slice(result.pos)}
|
|
|
13987
14051
|
insertReturn(exp.children[2][3]);
|
|
13988
14052
|
return;
|
|
13989
14053
|
}
|
|
14054
|
+
if (node[node.length - 1]?.type === "SemicolonDelimiter")
|
|
14055
|
+
return;
|
|
13990
14056
|
node.splice(1, 0, "return ");
|
|
13991
14057
|
}
|
|
13992
14058
|
module.isWhitespaceOrEmpty = function(node) {
|
|
@@ -13994,6 +14060,8 @@ ${input.slice(result.pos)}
|
|
|
13994
14060
|
return true;
|
|
13995
14061
|
if (node.token)
|
|
13996
14062
|
return node.token.match(/^\s*$/);
|
|
14063
|
+
if (node.children)
|
|
14064
|
+
node = node.children;
|
|
13997
14065
|
if (!node.length)
|
|
13998
14066
|
return true;
|
|
13999
14067
|
if (typeof node === "string")
|
|
@@ -14588,6 +14656,8 @@ ${input.slice(result.pos)}
|
|
|
14588
14656
|
insertBeforeAssignment(node, ["let ", undeclaredIdentifiers.join(", "), "\n"]);
|
|
14589
14657
|
}
|
|
14590
14658
|
} else if (node.type == "Declaration") {
|
|
14659
|
+
if (node.children && node.children.length)
|
|
14660
|
+
createLetDecs(node.children, scopes);
|
|
14591
14661
|
node.names.forEach((name) => currentScope.add(name));
|
|
14592
14662
|
} else {
|
|
14593
14663
|
let block = node;
|
|
@@ -14646,7 +14716,7 @@ ${input.slice(result.pos)}
|
|
|
14646
14716
|
}
|
|
14647
14717
|
};
|
|
14648
14718
|
module.constructPipeStep = function(caller, callee) {
|
|
14649
|
-
if (caller.expr.token === "yield" || caller.expr.token === "await") {
|
|
14719
|
+
if (caller.expr.token === "yield" || caller.expr.token === "await" || caller.expr.token === "return") {
|
|
14650
14720
|
return [caller.leadingComment, caller.expr, caller.trailingComment, " ", callee.leadingComment, callee.expr, callee.trailingComment];
|
|
14651
14721
|
}
|
|
14652
14722
|
return module.constructInvocation(caller, callee);
|
package/dist/main.js
CHANGED
|
@@ -440,6 +440,7 @@ ${input.slice(result.pos)}
|
|
|
440
440
|
ParenthesizedExpression,
|
|
441
441
|
ClassDeclaration,
|
|
442
442
|
ClassExpression,
|
|
443
|
+
ClassBinding,
|
|
443
444
|
ClassHeritage,
|
|
444
445
|
ExtendsClause,
|
|
445
446
|
ExtendsToken,
|
|
@@ -691,6 +692,7 @@ ${input.slice(result.pos)}
|
|
|
691
692
|
Whitespace,
|
|
692
693
|
ExpressionDelimiter,
|
|
693
694
|
StatementDelimiter,
|
|
695
|
+
SemicolonDelimiter,
|
|
694
696
|
NonIdContinue,
|
|
695
697
|
Loc,
|
|
696
698
|
Abstract,
|
|
@@ -2103,7 +2105,8 @@ ${input.slice(result.pos)}
|
|
|
2103
2105
|
}
|
|
2104
2106
|
var PipelineTailItem$0 = Await;
|
|
2105
2107
|
var PipelineTailItem$1 = Yield;
|
|
2106
|
-
var PipelineTailItem$2 =
|
|
2108
|
+
var PipelineTailItem$2 = Return;
|
|
2109
|
+
var PipelineTailItem$3 = PipelineHeadItem;
|
|
2107
2110
|
function PipelineTailItem(state) {
|
|
2108
2111
|
if (state.events) {
|
|
2109
2112
|
const result = state.events.enter?.("PipelineTailItem", state);
|
|
@@ -2111,12 +2114,12 @@ ${input.slice(result.pos)}
|
|
|
2111
2114
|
return result.cache;
|
|
2112
2115
|
}
|
|
2113
2116
|
if (state.tokenize) {
|
|
2114
|
-
const result = $TOKEN("PipelineTailItem", state, PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state));
|
|
2117
|
+
const result = $TOKEN("PipelineTailItem", state, PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state));
|
|
2115
2118
|
if (state.events)
|
|
2116
2119
|
state.events.exit?.("PipelineTailItem", state, result);
|
|
2117
2120
|
return result;
|
|
2118
2121
|
} else {
|
|
2119
|
-
const result = PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state);
|
|
2122
|
+
const result = PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state);
|
|
2120
2123
|
if (state.events)
|
|
2121
2124
|
state.events.exit?.("PipelineTailItem", state, result);
|
|
2122
2125
|
return result;
|
|
@@ -2201,7 +2204,7 @@ ${input.slice(result.pos)}
|
|
|
2201
2204
|
return result;
|
|
2202
2205
|
}
|
|
2203
2206
|
}
|
|
2204
|
-
var ClassExpression$0 = $TS($S($E(Decorators), $E($S(Abstract, __)), Class, $E(
|
|
2207
|
+
var ClassExpression$0 = $TS($S($E(Decorators), $E($S(Abstract, __)), Class, $E(ClassBinding), $E(ClassHeritage), ClassBody), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
2205
2208
|
return $0;
|
|
2206
2209
|
});
|
|
2207
2210
|
function ClassExpression(state) {
|
|
@@ -2222,6 +2225,27 @@ ${input.slice(result.pos)}
|
|
|
2222
2225
|
return result;
|
|
2223
2226
|
}
|
|
2224
2227
|
}
|
|
2228
|
+
var ClassBinding$0 = $T($S($N(EOS), BindingIdentifier, $E(TypeParameters)), function(value) {
|
|
2229
|
+
return [value[1], value[2]];
|
|
2230
|
+
});
|
|
2231
|
+
function ClassBinding(state) {
|
|
2232
|
+
if (state.events) {
|
|
2233
|
+
const result = state.events.enter?.("ClassBinding", state);
|
|
2234
|
+
if (result)
|
|
2235
|
+
return result.cache;
|
|
2236
|
+
}
|
|
2237
|
+
if (state.tokenize) {
|
|
2238
|
+
const result = $TOKEN("ClassBinding", state, ClassBinding$0(state));
|
|
2239
|
+
if (state.events)
|
|
2240
|
+
state.events.exit?.("ClassBinding", state, result);
|
|
2241
|
+
return result;
|
|
2242
|
+
} else {
|
|
2243
|
+
const result = ClassBinding$0(state);
|
|
2244
|
+
if (state.events)
|
|
2245
|
+
state.events.exit?.("ClassBinding", state, result);
|
|
2246
|
+
return result;
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2225
2249
|
var ClassHeritage$0 = $S(ExtendsClause, $E(ImplementsClause));
|
|
2226
2250
|
var ClassHeritage$1 = ImplementsClause;
|
|
2227
2251
|
function ClassHeritage(state) {
|
|
@@ -4064,7 +4088,7 @@ ${input.slice(result.pos)}
|
|
|
4064
4088
|
return result;
|
|
4065
4089
|
}
|
|
4066
4090
|
}
|
|
4067
|
-
var SingleLineStatements$0 = $TS($S($S($Q(TrailingComment), Statement), $Q($S(
|
|
4091
|
+
var SingleLineStatements$0 = $TS($S($S($Q(TrailingComment), Statement), $Q($S(SemicolonDelimiter, $E(Statement)))), function($skip, $loc, $0, $1, $2) {
|
|
4068
4092
|
var first = $1;
|
|
4069
4093
|
var rest = $2;
|
|
4070
4094
|
if (rest.length) {
|
|
@@ -5300,7 +5324,7 @@ ${input.slice(result.pos)}
|
|
|
5300
5324
|
ts: true
|
|
5301
5325
|
};
|
|
5302
5326
|
});
|
|
5303
|
-
var MethodDefinition$1 = $TS($S(MethodSignature,
|
|
5327
|
+
var MethodDefinition$1 = $TS($S(MethodSignature, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2) {
|
|
5304
5328
|
var signature = $1;
|
|
5305
5329
|
var block = $2;
|
|
5306
5330
|
return {
|
|
@@ -9255,7 +9279,7 @@ ${input.slice(result.pos)}
|
|
|
9255
9279
|
return result;
|
|
9256
9280
|
}
|
|
9257
9281
|
}
|
|
9258
|
-
var StatementDelimiter$0 =
|
|
9282
|
+
var StatementDelimiter$0 = SemicolonDelimiter;
|
|
9259
9283
|
var StatementDelimiter$1 = $Y(EOS);
|
|
9260
9284
|
function StatementDelimiter(state) {
|
|
9261
9285
|
if (state.events) {
|
|
@@ -9275,6 +9299,30 @@ ${input.slice(result.pos)}
|
|
|
9275
9299
|
return result;
|
|
9276
9300
|
}
|
|
9277
9301
|
}
|
|
9302
|
+
var SemicolonDelimiter$0 = $TS($S($Q(TrailingComment), Semicolon, $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3) {
|
|
9303
|
+
return {
|
|
9304
|
+
type: "SemicolonDelimiter",
|
|
9305
|
+
children: $0
|
|
9306
|
+
};
|
|
9307
|
+
});
|
|
9308
|
+
function SemicolonDelimiter(state) {
|
|
9309
|
+
if (state.events) {
|
|
9310
|
+
const result = state.events.enter?.("SemicolonDelimiter", state);
|
|
9311
|
+
if (result)
|
|
9312
|
+
return result.cache;
|
|
9313
|
+
}
|
|
9314
|
+
if (state.tokenize) {
|
|
9315
|
+
const result = $TOKEN("SemicolonDelimiter", state, SemicolonDelimiter$0(state));
|
|
9316
|
+
if (state.events)
|
|
9317
|
+
state.events.exit?.("SemicolonDelimiter", state, result);
|
|
9318
|
+
return result;
|
|
9319
|
+
} else {
|
|
9320
|
+
const result = SemicolonDelimiter$0(state);
|
|
9321
|
+
if (state.events)
|
|
9322
|
+
state.events.exit?.("SemicolonDelimiter", state, result);
|
|
9323
|
+
return result;
|
|
9324
|
+
}
|
|
9325
|
+
}
|
|
9278
9326
|
var NonIdContinue$0 = $R$0($EXPECT($R43, fail, "NonIdContinue /(?!\\p{ID_Continue})/"));
|
|
9279
9327
|
function NonIdContinue(state) {
|
|
9280
9328
|
if (state.events) {
|
|
@@ -11154,7 +11202,23 @@ ${input.slice(result.pos)}
|
|
|
11154
11202
|
if (stringPart) {
|
|
11155
11203
|
exprs.unshift(JSON.stringify(stringPart), ", ");
|
|
11156
11204
|
}
|
|
11157
|
-
|
|
11205
|
+
if (exprs.length === 1) {
|
|
11206
|
+
let root = exprs[0];
|
|
11207
|
+
while (root.length && module2.isWhitespaceOrEmpty(root[root.length - 1])) {
|
|
11208
|
+
root = root.slice(0, -1);
|
|
11209
|
+
}
|
|
11210
|
+
while (root?.length === 1)
|
|
11211
|
+
root = root[0];
|
|
11212
|
+
if (root?.children)
|
|
11213
|
+
root = root.children;
|
|
11214
|
+
if (root?.[0]?.token === "`") {
|
|
11215
|
+
classValue = ["{", ...exprs, "}"];
|
|
11216
|
+
} else {
|
|
11217
|
+
classValue = ["{(", ...exprs, ') || ""}'];
|
|
11218
|
+
}
|
|
11219
|
+
} else {
|
|
11220
|
+
classValue = ["{[", ...exprs, '].filter(Boolean).join(" ")}'];
|
|
11221
|
+
}
|
|
11158
11222
|
} else {
|
|
11159
11223
|
classValue = JSON.stringify(stringPart);
|
|
11160
11224
|
}
|
|
@@ -13986,6 +14050,8 @@ ${input.slice(result.pos)}
|
|
|
13986
14050
|
insertReturn(exp.children[2][3]);
|
|
13987
14051
|
return;
|
|
13988
14052
|
}
|
|
14053
|
+
if (node[node.length - 1]?.type === "SemicolonDelimiter")
|
|
14054
|
+
return;
|
|
13989
14055
|
node.splice(1, 0, "return ");
|
|
13990
14056
|
}
|
|
13991
14057
|
module2.isWhitespaceOrEmpty = function(node) {
|
|
@@ -13993,6 +14059,8 @@ ${input.slice(result.pos)}
|
|
|
13993
14059
|
return true;
|
|
13994
14060
|
if (node.token)
|
|
13995
14061
|
return node.token.match(/^\s*$/);
|
|
14062
|
+
if (node.children)
|
|
14063
|
+
node = node.children;
|
|
13996
14064
|
if (!node.length)
|
|
13997
14065
|
return true;
|
|
13998
14066
|
if (typeof node === "string")
|
|
@@ -14587,6 +14655,8 @@ ${input.slice(result.pos)}
|
|
|
14587
14655
|
insertBeforeAssignment(node, ["let ", undeclaredIdentifiers.join(", "), "\n"]);
|
|
14588
14656
|
}
|
|
14589
14657
|
} else if (node.type == "Declaration") {
|
|
14658
|
+
if (node.children && node.children.length)
|
|
14659
|
+
createLetDecs(node.children, scopes);
|
|
14590
14660
|
node.names.forEach((name) => currentScope.add(name));
|
|
14591
14661
|
} else {
|
|
14592
14662
|
let block = node;
|
|
@@ -14645,7 +14715,7 @@ ${input.slice(result.pos)}
|
|
|
14645
14715
|
}
|
|
14646
14716
|
};
|
|
14647
14717
|
module2.constructPipeStep = function(caller, callee) {
|
|
14648
|
-
if (caller.expr.token === "yield" || caller.expr.token === "await") {
|
|
14718
|
+
if (caller.expr.token === "yield" || caller.expr.token === "await" || caller.expr.token === "return") {
|
|
14649
14719
|
return [caller.leadingComment, caller.expr, caller.trailingComment, " ", callee.leadingComment, callee.expr, callee.trailingComment];
|
|
14650
14720
|
}
|
|
14651
14721
|
return module2.constructInvocation(caller, callee);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielx/civet",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.21",
|
|
4
4
|
"description": "CoffeeScript style syntax for TypeScript",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"exports": {
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "bash ./build/build.sh",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"docs:dev": "vitepress dev civet.dev",
|
|
26
|
+
"docs:build": "vitepress build civet.dev",
|
|
27
|
+
"docs:preview": "vitepress preview civet.dev",
|
|
27
28
|
"prepublishOnly": "yarn build && yarn test",
|
|
28
29
|
"test": "c8 mocha"
|
|
29
30
|
},
|
|
@@ -42,7 +43,9 @@
|
|
|
42
43
|
"mocha": "^10.0.0",
|
|
43
44
|
"ts-node": "^10.9.1",
|
|
44
45
|
"tslib": "^2.4.0",
|
|
45
|
-
"typescript": "^4.7.4"
|
|
46
|
+
"typescript": "^4.7.4",
|
|
47
|
+
"vitepress": "^1.0.0-alpha.35",
|
|
48
|
+
"vue": "^3.2.45"
|
|
46
49
|
},
|
|
47
50
|
"c8": {
|
|
48
51
|
"all": true,
|