@danielx/civet 0.5.20 → 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 +12 -0
- package/dist/browser.js +26 -2
- package/dist/main.js +26 -2
- 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"`
|
|
@@ -310,6 +312,16 @@ You can use these with `"civet coffeeCompat"` to opt in to all or use them bit b
|
|
|
310
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"`.
|
|
311
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.
|
|
312
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
|
+
|
|
313
325
|
Other Options
|
|
314
326
|
---
|
|
315
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,
|
|
@@ -2204,7 +2205,7 @@ ${input.slice(result.pos)}
|
|
|
2204
2205
|
return result;
|
|
2205
2206
|
}
|
|
2206
2207
|
}
|
|
2207
|
-
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) {
|
|
2208
2209
|
return $0;
|
|
2209
2210
|
});
|
|
2210
2211
|
function ClassExpression(state) {
|
|
@@ -2225,6 +2226,27 @@ ${input.slice(result.pos)}
|
|
|
2225
2226
|
return result;
|
|
2226
2227
|
}
|
|
2227
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
|
+
}
|
|
2228
2250
|
var ClassHeritage$0 = $S(ExtendsClause, $E(ImplementsClause));
|
|
2229
2251
|
var ClassHeritage$1 = ImplementsClause;
|
|
2230
2252
|
function ClassHeritage(state) {
|
|
@@ -5303,7 +5325,7 @@ ${input.slice(result.pos)}
|
|
|
5303
5325
|
ts: true
|
|
5304
5326
|
};
|
|
5305
5327
|
});
|
|
5306
|
-
var MethodDefinition$1 = $TS($S(MethodSignature,
|
|
5328
|
+
var MethodDefinition$1 = $TS($S(MethodSignature, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2) {
|
|
5307
5329
|
var signature = $1;
|
|
5308
5330
|
var block = $2;
|
|
5309
5331
|
return {
|
|
@@ -14634,6 +14656,8 @@ ${input.slice(result.pos)}
|
|
|
14634
14656
|
insertBeforeAssignment(node, ["let ", undeclaredIdentifiers.join(", "), "\n"]);
|
|
14635
14657
|
}
|
|
14636
14658
|
} else if (node.type == "Declaration") {
|
|
14659
|
+
if (node.children && node.children.length)
|
|
14660
|
+
createLetDecs(node.children, scopes);
|
|
14637
14661
|
node.names.forEach((name) => currentScope.add(name));
|
|
14638
14662
|
} else {
|
|
14639
14663
|
let block = node;
|
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,
|
|
@@ -2203,7 +2204,7 @@ ${input.slice(result.pos)}
|
|
|
2203
2204
|
return result;
|
|
2204
2205
|
}
|
|
2205
2206
|
}
|
|
2206
|
-
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) {
|
|
2207
2208
|
return $0;
|
|
2208
2209
|
});
|
|
2209
2210
|
function ClassExpression(state) {
|
|
@@ -2224,6 +2225,27 @@ ${input.slice(result.pos)}
|
|
|
2224
2225
|
return result;
|
|
2225
2226
|
}
|
|
2226
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
|
+
}
|
|
2227
2249
|
var ClassHeritage$0 = $S(ExtendsClause, $E(ImplementsClause));
|
|
2228
2250
|
var ClassHeritage$1 = ImplementsClause;
|
|
2229
2251
|
function ClassHeritage(state) {
|
|
@@ -5302,7 +5324,7 @@ ${input.slice(result.pos)}
|
|
|
5302
5324
|
ts: true
|
|
5303
5325
|
};
|
|
5304
5326
|
});
|
|
5305
|
-
var MethodDefinition$1 = $TS($S(MethodSignature,
|
|
5327
|
+
var MethodDefinition$1 = $TS($S(MethodSignature, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2) {
|
|
5306
5328
|
var signature = $1;
|
|
5307
5329
|
var block = $2;
|
|
5308
5330
|
return {
|
|
@@ -14633,6 +14655,8 @@ ${input.slice(result.pos)}
|
|
|
14633
14655
|
insertBeforeAssignment(node, ["let ", undeclaredIdentifiers.join(", "), "\n"]);
|
|
14634
14656
|
}
|
|
14635
14657
|
} else if (node.type == "Declaration") {
|
|
14658
|
+
if (node.children && node.children.length)
|
|
14659
|
+
createLetDecs(node.children, scopes);
|
|
14636
14660
|
node.names.forEach((name) => currentScope.add(name));
|
|
14637
14661
|
} else {
|
|
14638
14662
|
let block = node;
|
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,
|