@danielx/civet 0.5.19 → 0.5.20
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 +13 -1
- package/dist/browser.js +53 -7
- package/dist/main.js +53 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -193,6 +193,9 @@ Things Added that CoffeeScript didn't
|
|
|
193
193
|
- Private identifiers `#id`
|
|
194
194
|
- Convenience for ES6+ Features
|
|
195
195
|
- Const assignment shorthand: `a := b` → `const a = b`, `{a, b} := c` → `const {a, b} = c`
|
|
196
|
+
- Let assignment shorthand (experimental): `a .= b` or `a ::= b` → `let a = b`
|
|
197
|
+
- Typed versions of above: `a: number .= 5` → `let a: number = 5`
|
|
198
|
+
(but note that `a: number = 5` is the object literal `{a: (number = 5)}`).
|
|
196
199
|
- `@#id` → `this.#id` shorthand for private identifiers
|
|
197
200
|
- `import` shorthand: `x from ./x` → `import x from "./x"`
|
|
198
201
|
- Dynamic `import` shorthand: `import './x'` not at top level
|
|
@@ -209,6 +212,13 @@ Things Added that CoffeeScript didn't
|
|
|
209
212
|
- Function call: `x.map &.callback a, b` → `x.map($ => $.callback(a, b))`
|
|
210
213
|
- Unary operators: `x.map !!&` → `x.map($ => !!$)`
|
|
211
214
|
- Binary operators: `x.map &+1` → `x.map($ => $+1)`
|
|
215
|
+
- 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))
|
|
216
|
+
- `data |> Object.keys |> console.log` equivalent to
|
|
217
|
+
`console.log(Object.keys(data))`
|
|
218
|
+
- Use single-argument arrow functions or `&` shorthand
|
|
219
|
+
to specify how to use left-hand side
|
|
220
|
+
- `|> await`, `|> yield`, and `|> return` (at end)
|
|
221
|
+
for wrapping left-hand side with that operation
|
|
212
222
|
- Flagging shorthand [from LiveScript](https://livescript.net/#literals) `{+debug, -live}` → `{debug: true, live: false}`
|
|
213
223
|
- JSX enhancements (inspired by [solid-dsl discussions](https://github.com/solidjs-community/solid-dsl/discussions)):
|
|
214
224
|
- Indentation: instead of explicitly closing `<tag>`s or `<>`s,
|
|
@@ -252,7 +262,9 @@ Things Added that CoffeeScript didn't
|
|
|
252
262
|
Things Changed from ES6
|
|
253
263
|
---
|
|
254
264
|
|
|
255
|
-
- Implicit returns
|
|
265
|
+
- Implicit returns, even for multi-statement functions
|
|
266
|
+
(avoid by adding a trailing `;`, an explicit `return`, or
|
|
267
|
+
via the directive `"civet -implicitReturns"`)
|
|
256
268
|
- Disallow no parens on single argument arrow function. `x => ...` must become `(x) => ...`
|
|
257
269
|
The reasoning is `x -> ...` => `x(function() ...)` in CoffeeScript and having `->` and `=>`
|
|
258
270
|
behave more differently than they already do is bad. Passing an anonymous function to an
|
package/dist/browser.js
CHANGED
|
@@ -692,6 +692,7 @@ ${input.slice(result.pos)}
|
|
|
692
692
|
Whitespace,
|
|
693
693
|
ExpressionDelimiter,
|
|
694
694
|
StatementDelimiter,
|
|
695
|
+
SemicolonDelimiter,
|
|
695
696
|
NonIdContinue,
|
|
696
697
|
Loc,
|
|
697
698
|
Abstract,
|
|
@@ -2104,7 +2105,8 @@ ${input.slice(result.pos)}
|
|
|
2104
2105
|
}
|
|
2105
2106
|
var PipelineTailItem$0 = Await;
|
|
2106
2107
|
var PipelineTailItem$1 = Yield;
|
|
2107
|
-
var PipelineTailItem$2 =
|
|
2108
|
+
var PipelineTailItem$2 = Return;
|
|
2109
|
+
var PipelineTailItem$3 = PipelineHeadItem;
|
|
2108
2110
|
function PipelineTailItem(state) {
|
|
2109
2111
|
if (state.events) {
|
|
2110
2112
|
const result = state.events.enter?.("PipelineTailItem", state);
|
|
@@ -2112,12 +2114,12 @@ ${input.slice(result.pos)}
|
|
|
2112
2114
|
return result.cache;
|
|
2113
2115
|
}
|
|
2114
2116
|
if (state.tokenize) {
|
|
2115
|
-
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));
|
|
2116
2118
|
if (state.events)
|
|
2117
2119
|
state.events.exit?.("PipelineTailItem", state, result);
|
|
2118
2120
|
return result;
|
|
2119
2121
|
} else {
|
|
2120
|
-
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);
|
|
2121
2123
|
if (state.events)
|
|
2122
2124
|
state.events.exit?.("PipelineTailItem", state, result);
|
|
2123
2125
|
return result;
|
|
@@ -4065,7 +4067,7 @@ ${input.slice(result.pos)}
|
|
|
4065
4067
|
return result;
|
|
4066
4068
|
}
|
|
4067
4069
|
}
|
|
4068
|
-
var SingleLineStatements$0 = $TS($S($S($Q(TrailingComment), Statement), $Q($S(
|
|
4070
|
+
var SingleLineStatements$0 = $TS($S($S($Q(TrailingComment), Statement), $Q($S(SemicolonDelimiter, $E(Statement)))), function($skip, $loc, $0, $1, $2) {
|
|
4069
4071
|
var first = $1;
|
|
4070
4072
|
var rest = $2;
|
|
4071
4073
|
if (rest.length) {
|
|
@@ -9256,7 +9258,7 @@ ${input.slice(result.pos)}
|
|
|
9256
9258
|
return result;
|
|
9257
9259
|
}
|
|
9258
9260
|
}
|
|
9259
|
-
var StatementDelimiter$0 =
|
|
9261
|
+
var StatementDelimiter$0 = SemicolonDelimiter;
|
|
9260
9262
|
var StatementDelimiter$1 = $Y(EOS);
|
|
9261
9263
|
function StatementDelimiter(state) {
|
|
9262
9264
|
if (state.events) {
|
|
@@ -9276,6 +9278,30 @@ ${input.slice(result.pos)}
|
|
|
9276
9278
|
return result;
|
|
9277
9279
|
}
|
|
9278
9280
|
}
|
|
9281
|
+
var SemicolonDelimiter$0 = $TS($S($Q(TrailingComment), Semicolon, $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3) {
|
|
9282
|
+
return {
|
|
9283
|
+
type: "SemicolonDelimiter",
|
|
9284
|
+
children: $0
|
|
9285
|
+
};
|
|
9286
|
+
});
|
|
9287
|
+
function SemicolonDelimiter(state) {
|
|
9288
|
+
if (state.events) {
|
|
9289
|
+
const result = state.events.enter?.("SemicolonDelimiter", state);
|
|
9290
|
+
if (result)
|
|
9291
|
+
return result.cache;
|
|
9292
|
+
}
|
|
9293
|
+
if (state.tokenize) {
|
|
9294
|
+
const result = $TOKEN("SemicolonDelimiter", state, SemicolonDelimiter$0(state));
|
|
9295
|
+
if (state.events)
|
|
9296
|
+
state.events.exit?.("SemicolonDelimiter", state, result);
|
|
9297
|
+
return result;
|
|
9298
|
+
} else {
|
|
9299
|
+
const result = SemicolonDelimiter$0(state);
|
|
9300
|
+
if (state.events)
|
|
9301
|
+
state.events.exit?.("SemicolonDelimiter", state, result);
|
|
9302
|
+
return result;
|
|
9303
|
+
}
|
|
9304
|
+
}
|
|
9279
9305
|
var NonIdContinue$0 = $R$0($EXPECT($R43, fail, "NonIdContinue /(?!\\p{ID_Continue})/"));
|
|
9280
9306
|
function NonIdContinue(state) {
|
|
9281
9307
|
if (state.events) {
|
|
@@ -11155,7 +11181,23 @@ ${input.slice(result.pos)}
|
|
|
11155
11181
|
if (stringPart) {
|
|
11156
11182
|
exprs.unshift(JSON.stringify(stringPart), ", ");
|
|
11157
11183
|
}
|
|
11158
|
-
|
|
11184
|
+
if (exprs.length === 1) {
|
|
11185
|
+
let root = exprs[0];
|
|
11186
|
+
while (root.length && module.isWhitespaceOrEmpty(root[root.length - 1])) {
|
|
11187
|
+
root = root.slice(0, -1);
|
|
11188
|
+
}
|
|
11189
|
+
while (root?.length === 1)
|
|
11190
|
+
root = root[0];
|
|
11191
|
+
if (root?.children)
|
|
11192
|
+
root = root.children;
|
|
11193
|
+
if (root?.[0]?.token === "`") {
|
|
11194
|
+
classValue = ["{", ...exprs, "}"];
|
|
11195
|
+
} else {
|
|
11196
|
+
classValue = ["{(", ...exprs, ') || ""}'];
|
|
11197
|
+
}
|
|
11198
|
+
} else {
|
|
11199
|
+
classValue = ["{[", ...exprs, '].filter(Boolean).join(" ")}'];
|
|
11200
|
+
}
|
|
11159
11201
|
} else {
|
|
11160
11202
|
classValue = JSON.stringify(stringPart);
|
|
11161
11203
|
}
|
|
@@ -13987,6 +14029,8 @@ ${input.slice(result.pos)}
|
|
|
13987
14029
|
insertReturn(exp.children[2][3]);
|
|
13988
14030
|
return;
|
|
13989
14031
|
}
|
|
14032
|
+
if (node[node.length - 1]?.type === "SemicolonDelimiter")
|
|
14033
|
+
return;
|
|
13990
14034
|
node.splice(1, 0, "return ");
|
|
13991
14035
|
}
|
|
13992
14036
|
module.isWhitespaceOrEmpty = function(node) {
|
|
@@ -13994,6 +14038,8 @@ ${input.slice(result.pos)}
|
|
|
13994
14038
|
return true;
|
|
13995
14039
|
if (node.token)
|
|
13996
14040
|
return node.token.match(/^\s*$/);
|
|
14041
|
+
if (node.children)
|
|
14042
|
+
node = node.children;
|
|
13997
14043
|
if (!node.length)
|
|
13998
14044
|
return true;
|
|
13999
14045
|
if (typeof node === "string")
|
|
@@ -14646,7 +14692,7 @@ ${input.slice(result.pos)}
|
|
|
14646
14692
|
}
|
|
14647
14693
|
};
|
|
14648
14694
|
module.constructPipeStep = function(caller, callee) {
|
|
14649
|
-
if (caller.expr.token === "yield" || caller.expr.token === "await") {
|
|
14695
|
+
if (caller.expr.token === "yield" || caller.expr.token === "await" || caller.expr.token === "return") {
|
|
14650
14696
|
return [caller.leadingComment, caller.expr, caller.trailingComment, " ", callee.leadingComment, callee.expr, callee.trailingComment];
|
|
14651
14697
|
}
|
|
14652
14698
|
return module.constructInvocation(caller, callee);
|
package/dist/main.js
CHANGED
|
@@ -691,6 +691,7 @@ ${input.slice(result.pos)}
|
|
|
691
691
|
Whitespace,
|
|
692
692
|
ExpressionDelimiter,
|
|
693
693
|
StatementDelimiter,
|
|
694
|
+
SemicolonDelimiter,
|
|
694
695
|
NonIdContinue,
|
|
695
696
|
Loc,
|
|
696
697
|
Abstract,
|
|
@@ -2103,7 +2104,8 @@ ${input.slice(result.pos)}
|
|
|
2103
2104
|
}
|
|
2104
2105
|
var PipelineTailItem$0 = Await;
|
|
2105
2106
|
var PipelineTailItem$1 = Yield;
|
|
2106
|
-
var PipelineTailItem$2 =
|
|
2107
|
+
var PipelineTailItem$2 = Return;
|
|
2108
|
+
var PipelineTailItem$3 = PipelineHeadItem;
|
|
2107
2109
|
function PipelineTailItem(state) {
|
|
2108
2110
|
if (state.events) {
|
|
2109
2111
|
const result = state.events.enter?.("PipelineTailItem", state);
|
|
@@ -2111,12 +2113,12 @@ ${input.slice(result.pos)}
|
|
|
2111
2113
|
return result.cache;
|
|
2112
2114
|
}
|
|
2113
2115
|
if (state.tokenize) {
|
|
2114
|
-
const result = $TOKEN("PipelineTailItem", state, PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state));
|
|
2116
|
+
const result = $TOKEN("PipelineTailItem", state, PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state));
|
|
2115
2117
|
if (state.events)
|
|
2116
2118
|
state.events.exit?.("PipelineTailItem", state, result);
|
|
2117
2119
|
return result;
|
|
2118
2120
|
} else {
|
|
2119
|
-
const result = PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state);
|
|
2121
|
+
const result = PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state);
|
|
2120
2122
|
if (state.events)
|
|
2121
2123
|
state.events.exit?.("PipelineTailItem", state, result);
|
|
2122
2124
|
return result;
|
|
@@ -4064,7 +4066,7 @@ ${input.slice(result.pos)}
|
|
|
4064
4066
|
return result;
|
|
4065
4067
|
}
|
|
4066
4068
|
}
|
|
4067
|
-
var SingleLineStatements$0 = $TS($S($S($Q(TrailingComment), Statement), $Q($S(
|
|
4069
|
+
var SingleLineStatements$0 = $TS($S($S($Q(TrailingComment), Statement), $Q($S(SemicolonDelimiter, $E(Statement)))), function($skip, $loc, $0, $1, $2) {
|
|
4068
4070
|
var first = $1;
|
|
4069
4071
|
var rest = $2;
|
|
4070
4072
|
if (rest.length) {
|
|
@@ -9255,7 +9257,7 @@ ${input.slice(result.pos)}
|
|
|
9255
9257
|
return result;
|
|
9256
9258
|
}
|
|
9257
9259
|
}
|
|
9258
|
-
var StatementDelimiter$0 =
|
|
9260
|
+
var StatementDelimiter$0 = SemicolonDelimiter;
|
|
9259
9261
|
var StatementDelimiter$1 = $Y(EOS);
|
|
9260
9262
|
function StatementDelimiter(state) {
|
|
9261
9263
|
if (state.events) {
|
|
@@ -9275,6 +9277,30 @@ ${input.slice(result.pos)}
|
|
|
9275
9277
|
return result;
|
|
9276
9278
|
}
|
|
9277
9279
|
}
|
|
9280
|
+
var SemicolonDelimiter$0 = $TS($S($Q(TrailingComment), Semicolon, $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3) {
|
|
9281
|
+
return {
|
|
9282
|
+
type: "SemicolonDelimiter",
|
|
9283
|
+
children: $0
|
|
9284
|
+
};
|
|
9285
|
+
});
|
|
9286
|
+
function SemicolonDelimiter(state) {
|
|
9287
|
+
if (state.events) {
|
|
9288
|
+
const result = state.events.enter?.("SemicolonDelimiter", state);
|
|
9289
|
+
if (result)
|
|
9290
|
+
return result.cache;
|
|
9291
|
+
}
|
|
9292
|
+
if (state.tokenize) {
|
|
9293
|
+
const result = $TOKEN("SemicolonDelimiter", state, SemicolonDelimiter$0(state));
|
|
9294
|
+
if (state.events)
|
|
9295
|
+
state.events.exit?.("SemicolonDelimiter", state, result);
|
|
9296
|
+
return result;
|
|
9297
|
+
} else {
|
|
9298
|
+
const result = SemicolonDelimiter$0(state);
|
|
9299
|
+
if (state.events)
|
|
9300
|
+
state.events.exit?.("SemicolonDelimiter", state, result);
|
|
9301
|
+
return result;
|
|
9302
|
+
}
|
|
9303
|
+
}
|
|
9278
9304
|
var NonIdContinue$0 = $R$0($EXPECT($R43, fail, "NonIdContinue /(?!\\p{ID_Continue})/"));
|
|
9279
9305
|
function NonIdContinue(state) {
|
|
9280
9306
|
if (state.events) {
|
|
@@ -11154,7 +11180,23 @@ ${input.slice(result.pos)}
|
|
|
11154
11180
|
if (stringPart) {
|
|
11155
11181
|
exprs.unshift(JSON.stringify(stringPart), ", ");
|
|
11156
11182
|
}
|
|
11157
|
-
|
|
11183
|
+
if (exprs.length === 1) {
|
|
11184
|
+
let root = exprs[0];
|
|
11185
|
+
while (root.length && module2.isWhitespaceOrEmpty(root[root.length - 1])) {
|
|
11186
|
+
root = root.slice(0, -1);
|
|
11187
|
+
}
|
|
11188
|
+
while (root?.length === 1)
|
|
11189
|
+
root = root[0];
|
|
11190
|
+
if (root?.children)
|
|
11191
|
+
root = root.children;
|
|
11192
|
+
if (root?.[0]?.token === "`") {
|
|
11193
|
+
classValue = ["{", ...exprs, "}"];
|
|
11194
|
+
} else {
|
|
11195
|
+
classValue = ["{(", ...exprs, ') || ""}'];
|
|
11196
|
+
}
|
|
11197
|
+
} else {
|
|
11198
|
+
classValue = ["{[", ...exprs, '].filter(Boolean).join(" ")}'];
|
|
11199
|
+
}
|
|
11158
11200
|
} else {
|
|
11159
11201
|
classValue = JSON.stringify(stringPart);
|
|
11160
11202
|
}
|
|
@@ -13986,6 +14028,8 @@ ${input.slice(result.pos)}
|
|
|
13986
14028
|
insertReturn(exp.children[2][3]);
|
|
13987
14029
|
return;
|
|
13988
14030
|
}
|
|
14031
|
+
if (node[node.length - 1]?.type === "SemicolonDelimiter")
|
|
14032
|
+
return;
|
|
13989
14033
|
node.splice(1, 0, "return ");
|
|
13990
14034
|
}
|
|
13991
14035
|
module2.isWhitespaceOrEmpty = function(node) {
|
|
@@ -13993,6 +14037,8 @@ ${input.slice(result.pos)}
|
|
|
13993
14037
|
return true;
|
|
13994
14038
|
if (node.token)
|
|
13995
14039
|
return node.token.match(/^\s*$/);
|
|
14040
|
+
if (node.children)
|
|
14041
|
+
node = node.children;
|
|
13996
14042
|
if (!node.length)
|
|
13997
14043
|
return true;
|
|
13998
14044
|
if (typeof node === "string")
|
|
@@ -14645,7 +14691,7 @@ ${input.slice(result.pos)}
|
|
|
14645
14691
|
}
|
|
14646
14692
|
};
|
|
14647
14693
|
module2.constructPipeStep = function(caller, callee) {
|
|
14648
|
-
if (caller.expr.token === "yield" || caller.expr.token === "await") {
|
|
14694
|
+
if (caller.expr.token === "yield" || caller.expr.token === "await" || caller.expr.token === "return") {
|
|
14649
14695
|
return [caller.leadingComment, caller.expr, caller.trailingComment, " ", callee.leadingComment, callee.expr, callee.trailingComment];
|
|
14650
14696
|
}
|
|
14651
14697
|
return module2.constructInvocation(caller, callee);
|