@danielx/civet 0.5.5 → 0.5.6
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 +6 -1
- package/dist/browser.js +17 -6
- package/dist/main.js +17 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,6 +11,11 @@ The CoffeeScript of TypeScript. Much closer to ES2015+ (for better or worse).
|
|
|
11
11
|
- [Online Civet Playground](https://civet-web.vercel.app/)
|
|
12
12
|
- [Civet VSCode Extension](https://marketplace.visualstudio.com/items?itemName=DanielX.civet)
|
|
13
13
|
- [Discord Server](https://discord.gg/xkrW9GebBc)
|
|
14
|
+
- Plugins for
|
|
15
|
+
[Vite](https://github.com/lorefnon/vite-plugin-civet),
|
|
16
|
+
[esbuild](source/esbuild-plugin.civet),
|
|
17
|
+
[ESM module resolution](source/esm.civet)
|
|
18
|
+
- Starter templates for [Solid](https://github.com/orenelbaum/solid-civet-template) and [Solid Start](https://github.com/orenelbaum/solid-start-civet-template)
|
|
14
19
|
|
|
15
20
|
Quickstart Guide
|
|
16
21
|
---
|
|
@@ -240,7 +245,7 @@ Things Changed from ES6
|
|
|
240
245
|
behave more differently than they already do is bad. Passing an anonymous function to an
|
|
241
246
|
application without parens is also convenient.
|
|
242
247
|
- `for(i of x) ...` defaults to const declaration → `for(const i of x) ...`
|
|
243
|
-
- Disallow comma operator in conditionals and many other places. `if x, y` is not allowed.
|
|
248
|
+
- Disallow comma operator in conditionals and many other places. `if x, y` is not allowed. But `for i = 0, l = a.length; i < l; i++, i *= 2` is allowed.
|
|
244
249
|
- Comma operator in `case`/`when` instead becomes multiple conditions.
|
|
245
250
|
- Numbers can't end with a dot (otherwise would be ambiguous with CoffeeScript slices `y[0..x]`). This also implies that you can't access properties
|
|
246
251
|
of numbers with `1..toString()` use `1.toString()` instead. When exponent follows a dot it is treated as a property access since an exponent
|
package/dist/browser.js
CHANGED
|
@@ -2722,6 +2722,7 @@ ${input.slice(result.pos)}
|
|
|
2722
2722
|
}
|
|
2723
2723
|
}
|
|
2724
2724
|
var SuperProperty$0 = $S($EXPECT($L13, fail, 'SuperProperty "super["'), ExtendedExpression, __, CloseBracket);
|
|
2725
|
+
var SuperProperty$1 = $S($EXPECT($L10, fail, 'SuperProperty "super"'), $N($C(QuestionMark, NonNullAssertion)), PropertyAccess);
|
|
2725
2726
|
function SuperProperty(state) {
|
|
2726
2727
|
if (state.events) {
|
|
2727
2728
|
const result = state.events.enter?.("SuperProperty", state);
|
|
@@ -2729,12 +2730,12 @@ ${input.slice(result.pos)}
|
|
|
2729
2730
|
return result.cache;
|
|
2730
2731
|
}
|
|
2731
2732
|
if (state.tokenize) {
|
|
2732
|
-
const result = $TOKEN("SuperProperty", state, SuperProperty$0(state));
|
|
2733
|
+
const result = $TOKEN("SuperProperty", state, SuperProperty$0(state) || SuperProperty$1(state));
|
|
2733
2734
|
if (state.events)
|
|
2734
2735
|
state.events.exit?.("SuperProperty", state, result);
|
|
2735
2736
|
return result;
|
|
2736
2737
|
} else {
|
|
2737
|
-
const result = SuperProperty$0(state);
|
|
2738
|
+
const result = SuperProperty$0(state) || SuperProperty$1(state);
|
|
2738
2739
|
if (state.events)
|
|
2739
2740
|
state.events.exit?.("SuperProperty", state, result);
|
|
2740
2741
|
return result;
|
|
@@ -13727,12 +13728,12 @@ ${input.slice(result.pos)}
|
|
|
13727
13728
|
if (node == null)
|
|
13728
13729
|
return [];
|
|
13729
13730
|
if (Array.isArray(node)) {
|
|
13730
|
-
return node.flatMap((n) =>
|
|
13731
|
+
return node.flatMap((n) => gatherRecursive(n, predicate));
|
|
13731
13732
|
}
|
|
13732
13733
|
if (predicate(node)) {
|
|
13733
13734
|
return [node];
|
|
13734
13735
|
}
|
|
13735
|
-
return
|
|
13736
|
+
return gatherRecursive(node.children, predicate);
|
|
13736
13737
|
}
|
|
13737
13738
|
function gatherRecursiveAll(node, predicate) {
|
|
13738
13739
|
if (node == null)
|
|
@@ -14050,6 +14051,13 @@ ${input.slice(result.pos)}
|
|
|
14050
14051
|
function hasDec(name) {
|
|
14051
14052
|
return scopes.some((s) => s.has(name));
|
|
14052
14053
|
}
|
|
14054
|
+
function findVarDecs(statements2, decs) {
|
|
14055
|
+
const declarationNames = gatherRecursive(
|
|
14056
|
+
statements2,
|
|
14057
|
+
(node) => node.type === "Declaration" && node.children && node.children.length > 0 && node.children[0].token && node.children[0].token.startsWith("var") || node.type === "FunctionExpression"
|
|
14058
|
+
).filter((node) => node.type === "Declaration").flatMap((node) => node.names);
|
|
14059
|
+
return new Set(declarationNames);
|
|
14060
|
+
}
|
|
14053
14061
|
function insertBeforeAssignment(assignment, content) {
|
|
14054
14062
|
if (assignment.children && assignment.children.length) {
|
|
14055
14063
|
let indent = assignment.children[0][0][0];
|
|
@@ -14062,10 +14070,11 @@ ${input.slice(result.pos)}
|
|
|
14062
14070
|
scopes.push(currentScope);
|
|
14063
14071
|
const fnNodes = gatherNodes(statements, (s) => s.type === "FunctionExpression");
|
|
14064
14072
|
const forNodes = gatherNodes(statements, (s) => s.type === "ForStatement");
|
|
14065
|
-
const nodes = gatherNodes(statements, (s) => s.type === "BlockStatement" || s.type === "AssignmentExpression");
|
|
14073
|
+
const nodes = gatherNodes(statements, (s) => s.type === "BlockStatement" || s.type === "AssignmentExpression" || s.type === "Declaration");
|
|
14074
|
+
let declaredIdentifiers = findVarDecs(statements);
|
|
14066
14075
|
for (const node of nodes) {
|
|
14067
14076
|
if (node.type == "AssignmentExpression") {
|
|
14068
|
-
let undeclaredIdentifiers = node.names.filter((name) => !hasDec(name));
|
|
14077
|
+
let undeclaredIdentifiers = node.names.filter((name) => !(hasDec(name) || declaredIdentifiers.has(name)));
|
|
14069
14078
|
if (node.children.length)
|
|
14070
14079
|
createLetDecs(node.children, scopes);
|
|
14071
14080
|
undeclaredIdentifiers.forEach((name) => currentScope.add(name));
|
|
@@ -14074,6 +14083,8 @@ ${input.slice(result.pos)}
|
|
|
14074
14083
|
} else if (undeclaredIdentifiers.length > 0) {
|
|
14075
14084
|
insertBeforeAssignment(node, ["let ", undeclaredIdentifiers.join(", "), "\n"]);
|
|
14076
14085
|
}
|
|
14086
|
+
} else if (node.type == "Declaration") {
|
|
14087
|
+
node.names.forEach((name) => currentScope.add(name));
|
|
14077
14088
|
} else {
|
|
14078
14089
|
let block = node;
|
|
14079
14090
|
let fnNode = fnNodes.find((fnNode2) => fnNode2.block === block);
|
package/dist/main.js
CHANGED
|
@@ -2721,6 +2721,7 @@ ${input.slice(result.pos)}
|
|
|
2721
2721
|
}
|
|
2722
2722
|
}
|
|
2723
2723
|
var SuperProperty$0 = $S($EXPECT($L13, fail, 'SuperProperty "super["'), ExtendedExpression, __, CloseBracket);
|
|
2724
|
+
var SuperProperty$1 = $S($EXPECT($L10, fail, 'SuperProperty "super"'), $N($C(QuestionMark, NonNullAssertion)), PropertyAccess);
|
|
2724
2725
|
function SuperProperty(state) {
|
|
2725
2726
|
if (state.events) {
|
|
2726
2727
|
const result = state.events.enter?.("SuperProperty", state);
|
|
@@ -2728,12 +2729,12 @@ ${input.slice(result.pos)}
|
|
|
2728
2729
|
return result.cache;
|
|
2729
2730
|
}
|
|
2730
2731
|
if (state.tokenize) {
|
|
2731
|
-
const result = $TOKEN("SuperProperty", state, SuperProperty$0(state));
|
|
2732
|
+
const result = $TOKEN("SuperProperty", state, SuperProperty$0(state) || SuperProperty$1(state));
|
|
2732
2733
|
if (state.events)
|
|
2733
2734
|
state.events.exit?.("SuperProperty", state, result);
|
|
2734
2735
|
return result;
|
|
2735
2736
|
} else {
|
|
2736
|
-
const result = SuperProperty$0(state);
|
|
2737
|
+
const result = SuperProperty$0(state) || SuperProperty$1(state);
|
|
2737
2738
|
if (state.events)
|
|
2738
2739
|
state.events.exit?.("SuperProperty", state, result);
|
|
2739
2740
|
return result;
|
|
@@ -13726,12 +13727,12 @@ ${input.slice(result.pos)}
|
|
|
13726
13727
|
if (node == null)
|
|
13727
13728
|
return [];
|
|
13728
13729
|
if (Array.isArray(node)) {
|
|
13729
|
-
return node.flatMap((n) =>
|
|
13730
|
+
return node.flatMap((n) => gatherRecursive(n, predicate));
|
|
13730
13731
|
}
|
|
13731
13732
|
if (predicate(node)) {
|
|
13732
13733
|
return [node];
|
|
13733
13734
|
}
|
|
13734
|
-
return
|
|
13735
|
+
return gatherRecursive(node.children, predicate);
|
|
13735
13736
|
}
|
|
13736
13737
|
function gatherRecursiveAll(node, predicate) {
|
|
13737
13738
|
if (node == null)
|
|
@@ -14049,6 +14050,13 @@ ${input.slice(result.pos)}
|
|
|
14049
14050
|
function hasDec(name) {
|
|
14050
14051
|
return scopes.some((s) => s.has(name));
|
|
14051
14052
|
}
|
|
14053
|
+
function findVarDecs(statements2, decs) {
|
|
14054
|
+
const declarationNames = gatherRecursive(
|
|
14055
|
+
statements2,
|
|
14056
|
+
(node) => node.type === "Declaration" && node.children && node.children.length > 0 && node.children[0].token && node.children[0].token.startsWith("var") || node.type === "FunctionExpression"
|
|
14057
|
+
).filter((node) => node.type === "Declaration").flatMap((node) => node.names);
|
|
14058
|
+
return new Set(declarationNames);
|
|
14059
|
+
}
|
|
14052
14060
|
function insertBeforeAssignment(assignment, content) {
|
|
14053
14061
|
if (assignment.children && assignment.children.length) {
|
|
14054
14062
|
let indent = assignment.children[0][0][0];
|
|
@@ -14061,10 +14069,11 @@ ${input.slice(result.pos)}
|
|
|
14061
14069
|
scopes.push(currentScope);
|
|
14062
14070
|
const fnNodes = gatherNodes(statements, (s) => s.type === "FunctionExpression");
|
|
14063
14071
|
const forNodes = gatherNodes(statements, (s) => s.type === "ForStatement");
|
|
14064
|
-
const nodes = gatherNodes(statements, (s) => s.type === "BlockStatement" || s.type === "AssignmentExpression");
|
|
14072
|
+
const nodes = gatherNodes(statements, (s) => s.type === "BlockStatement" || s.type === "AssignmentExpression" || s.type === "Declaration");
|
|
14073
|
+
let declaredIdentifiers = findVarDecs(statements);
|
|
14065
14074
|
for (const node of nodes) {
|
|
14066
14075
|
if (node.type == "AssignmentExpression") {
|
|
14067
|
-
let undeclaredIdentifiers = node.names.filter((name) => !hasDec(name));
|
|
14076
|
+
let undeclaredIdentifiers = node.names.filter((name) => !(hasDec(name) || declaredIdentifiers.has(name)));
|
|
14068
14077
|
if (node.children.length)
|
|
14069
14078
|
createLetDecs(node.children, scopes);
|
|
14070
14079
|
undeclaredIdentifiers.forEach((name) => currentScope.add(name));
|
|
@@ -14073,6 +14082,8 @@ ${input.slice(result.pos)}
|
|
|
14073
14082
|
} else if (undeclaredIdentifiers.length > 0) {
|
|
14074
14083
|
insertBeforeAssignment(node, ["let ", undeclaredIdentifiers.join(", "), "\n"]);
|
|
14075
14084
|
}
|
|
14085
|
+
} else if (node.type == "Declaration") {
|
|
14086
|
+
node.names.forEach((name) => currentScope.add(name));
|
|
14076
14087
|
} else {
|
|
14077
14088
|
let block = node;
|
|
14078
14089
|
let fnNode = fnNodes.find((fnNode2) => fnNode2.block === block);
|