@danielx/civet 0.6.55 → 0.6.56

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 CHANGED
@@ -2428,6 +2428,32 @@ ${input.slice(result.pos)}
2428
2428
  }
2429
2429
  }
2430
2430
  }
2431
+ function processDeclarations(statements) {
2432
+ gatherRecursiveAll(statements, (n) => {
2433
+ return n.type === "Declaration";
2434
+ }).forEach(({ bindings }) => {
2435
+ return bindings?.forEach((binding) => {
2436
+ const { initializer } = binding;
2437
+ if (!initializer) {
2438
+ return;
2439
+ }
2440
+ const exp = initializer[2];
2441
+ if (exp?.type === "PipelineExpression") {
2442
+ if (exp.children.at(-2) === ",") {
2443
+ const { parent } = exp;
2444
+ const parenthesizedExpression = makeLeftHandSideExpression(exp);
2445
+ parenthesizedExpression.parent = parent;
2446
+ exp.parent = parenthesizedExpression;
2447
+ return initializer[2] = parenthesizedExpression;
2448
+ }
2449
+ ;
2450
+ return;
2451
+ }
2452
+ ;
2453
+ return;
2454
+ });
2455
+ });
2456
+ }
2431
2457
  function implicitFunctionBlock(f) {
2432
2458
  if (f.abstract || f.block || f.signature?.optional)
2433
2459
  return;
@@ -3164,6 +3190,7 @@ ${input.slice(result.pos)}
3164
3190
  const { expressions: statements } = root;
3165
3191
  processDeclarationConditions(statements);
3166
3192
  processPipelineExpressions(statements);
3193
+ processDeclarations(statements);
3167
3194
  processAssignments(statements);
3168
3195
  processPatternMatching(statements, ReservedWord);
3169
3196
  gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
@@ -7279,11 +7306,19 @@ ${input.slice(result.pos)}
7279
7306
  const expressions = [...stmts];
7280
7307
  if (last)
7281
7308
  expressions.push(last);
7309
+ const maybeComment = expressions.at(-1)?.[2]?.children?.[2]?.at(-1);
7310
+ let hasTrailingComment = false;
7311
+ if (maybeComment?.type === "Comment" && maybeComment.token.startsWith("//")) {
7312
+ hasTrailingComment = true;
7313
+ }
7314
+ const children = [expressions];
7315
+ if (hasTrailingComment) {
7316
+ children.push("\n");
7317
+ }
7282
7318
  return {
7283
7319
  type: "BlockStatement",
7284
7320
  expressions,
7285
- children: [expressions],
7286
- // avoid aliasing
7321
+ children,
7287
7322
  bare: true
7288
7323
  };
7289
7324
  });
@@ -9633,7 +9668,7 @@ ${input.slice(result.pos)}
9633
9668
  return $EVENT(ctx, state, "CatchClause", CatchClause$0);
9634
9669
  }
9635
9670
  var CatchBind$0 = $S($E(_), OpenParen, __, CatchParameter, __, CloseParen);
9636
- var CatchBind$1 = $S(_, InsertOpenParen, CatchParameter, InsertCloseParen);
9671
+ var CatchBind$1 = $S(_, InsertOpenParen, $N(EOS), CatchParameter, InsertCloseParen);
9637
9672
  var CatchBind$$ = [CatchBind$0, CatchBind$1];
9638
9673
  function CatchBind(ctx, state) {
9639
9674
  return $EVENT_C(ctx, state, "CatchBind", CatchBind$$);
package/dist/esbuild.js CHANGED
@@ -280,7 +280,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
280
280
  }
281
281
  }
282
282
  }
283
- const jsonSourceMap = typeof compiled.sourceMap == "string" ? compiled.sourceMap : compiled.sourceMap.json(
283
+ const jsonSourceMap = typeof compiled.sourceMap == "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
284
284
  import_path.default.basename(id.replace(/\.[jt]sx$/, "")),
285
285
  import_path.default.basename(id)
286
286
  );
package/dist/main.js CHANGED
@@ -2420,6 +2420,32 @@ var require_lib = __commonJS({
2420
2420
  }
2421
2421
  }
2422
2422
  }
2423
+ function processDeclarations(statements) {
2424
+ gatherRecursiveAll(statements, (n) => {
2425
+ return n.type === "Declaration";
2426
+ }).forEach(({ bindings }) => {
2427
+ return bindings?.forEach((binding) => {
2428
+ const { initializer } = binding;
2429
+ if (!initializer) {
2430
+ return;
2431
+ }
2432
+ const exp = initializer[2];
2433
+ if (exp?.type === "PipelineExpression") {
2434
+ if (exp.children.at(-2) === ",") {
2435
+ const { parent } = exp;
2436
+ const parenthesizedExpression = makeLeftHandSideExpression(exp);
2437
+ parenthesizedExpression.parent = parent;
2438
+ exp.parent = parenthesizedExpression;
2439
+ return initializer[2] = parenthesizedExpression;
2440
+ }
2441
+ ;
2442
+ return;
2443
+ }
2444
+ ;
2445
+ return;
2446
+ });
2447
+ });
2448
+ }
2423
2449
  function implicitFunctionBlock(f) {
2424
2450
  if (f.abstract || f.block || f.signature?.optional)
2425
2451
  return;
@@ -3156,6 +3182,7 @@ var require_lib = __commonJS({
3156
3182
  const { expressions: statements } = root;
3157
3183
  processDeclarationConditions(statements);
3158
3184
  processPipelineExpressions(statements);
3185
+ processDeclarations(statements);
3159
3186
  processAssignments(statements);
3160
3187
  processPatternMatching(statements, ReservedWord);
3161
3188
  gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
@@ -7271,11 +7298,19 @@ var require_parser = __commonJS({
7271
7298
  const expressions = [...stmts];
7272
7299
  if (last)
7273
7300
  expressions.push(last);
7301
+ const maybeComment = expressions.at(-1)?.[2]?.children?.[2]?.at(-1);
7302
+ let hasTrailingComment = false;
7303
+ if (maybeComment?.type === "Comment" && maybeComment.token.startsWith("//")) {
7304
+ hasTrailingComment = true;
7305
+ }
7306
+ const children = [expressions];
7307
+ if (hasTrailingComment) {
7308
+ children.push("\n");
7309
+ }
7274
7310
  return {
7275
7311
  type: "BlockStatement",
7276
7312
  expressions,
7277
- children: [expressions],
7278
- // avoid aliasing
7313
+ children,
7279
7314
  bare: true
7280
7315
  };
7281
7316
  });
@@ -9625,7 +9660,7 @@ var require_parser = __commonJS({
9625
9660
  return $EVENT(ctx, state, "CatchClause", CatchClause$0);
9626
9661
  }
9627
9662
  var CatchBind$0 = $S($E(_), OpenParen, __, CatchParameter, __, CloseParen);
9628
- var CatchBind$1 = $S(_, InsertOpenParen, CatchParameter, InsertCloseParen);
9663
+ var CatchBind$1 = $S(_, InsertOpenParen, $N(EOS), CatchParameter, InsertCloseParen);
9629
9664
  var CatchBind$$ = [CatchBind$0, CatchBind$1];
9630
9665
  function CatchBind(ctx, state) {
9631
9666
  return $EVENT_C(ctx, state, "CatchBind", CatchBind$$);
package/dist/main.mjs CHANGED
@@ -2418,6 +2418,32 @@ var require_lib = __commonJS({
2418
2418
  }
2419
2419
  }
2420
2420
  }
2421
+ function processDeclarations(statements) {
2422
+ gatherRecursiveAll(statements, (n) => {
2423
+ return n.type === "Declaration";
2424
+ }).forEach(({ bindings }) => {
2425
+ return bindings?.forEach((binding) => {
2426
+ const { initializer } = binding;
2427
+ if (!initializer) {
2428
+ return;
2429
+ }
2430
+ const exp = initializer[2];
2431
+ if (exp?.type === "PipelineExpression") {
2432
+ if (exp.children.at(-2) === ",") {
2433
+ const { parent } = exp;
2434
+ const parenthesizedExpression = makeLeftHandSideExpression(exp);
2435
+ parenthesizedExpression.parent = parent;
2436
+ exp.parent = parenthesizedExpression;
2437
+ return initializer[2] = parenthesizedExpression;
2438
+ }
2439
+ ;
2440
+ return;
2441
+ }
2442
+ ;
2443
+ return;
2444
+ });
2445
+ });
2446
+ }
2421
2447
  function implicitFunctionBlock(f) {
2422
2448
  if (f.abstract || f.block || f.signature?.optional)
2423
2449
  return;
@@ -3154,6 +3180,7 @@ var require_lib = __commonJS({
3154
3180
  const { expressions: statements } = root;
3155
3181
  processDeclarationConditions(statements);
3156
3182
  processPipelineExpressions(statements);
3183
+ processDeclarations(statements);
3157
3184
  processAssignments(statements);
3158
3185
  processPatternMatching(statements, ReservedWord);
3159
3186
  gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
@@ -7269,11 +7296,19 @@ var require_parser = __commonJS({
7269
7296
  const expressions = [...stmts];
7270
7297
  if (last)
7271
7298
  expressions.push(last);
7299
+ const maybeComment = expressions.at(-1)?.[2]?.children?.[2]?.at(-1);
7300
+ let hasTrailingComment = false;
7301
+ if (maybeComment?.type === "Comment" && maybeComment.token.startsWith("//")) {
7302
+ hasTrailingComment = true;
7303
+ }
7304
+ const children = [expressions];
7305
+ if (hasTrailingComment) {
7306
+ children.push("\n");
7307
+ }
7272
7308
  return {
7273
7309
  type: "BlockStatement",
7274
7310
  expressions,
7275
- children: [expressions],
7276
- // avoid aliasing
7311
+ children,
7277
7312
  bare: true
7278
7313
  };
7279
7314
  });
@@ -9623,7 +9658,7 @@ var require_parser = __commonJS({
9623
9658
  return $EVENT(ctx, state, "CatchClause", CatchClause$0);
9624
9659
  }
9625
9660
  var CatchBind$0 = $S($E(_), OpenParen, __, CatchParameter, __, CloseParen);
9626
- var CatchBind$1 = $S(_, InsertOpenParen, CatchParameter, InsertCloseParen);
9661
+ var CatchBind$1 = $S(_, InsertOpenParen, $N(EOS), CatchParameter, InsertCloseParen);
9627
9662
  var CatchBind$$ = [CatchBind$0, CatchBind$1];
9628
9663
  function CatchBind(ctx, state) {
9629
9664
  return $EVENT_C(ctx, state, "CatchBind", CatchBind$$);
package/dist/rollup.js CHANGED
@@ -280,7 +280,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
280
280
  }
281
281
  }
282
282
  }
283
- const jsonSourceMap = typeof compiled.sourceMap == "string" ? compiled.sourceMap : compiled.sourceMap.json(
283
+ const jsonSourceMap = typeof compiled.sourceMap == "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
284
284
  import_path.default.basename(id.replace(/\.[jt]sx$/, "")),
285
285
  import_path.default.basename(id)
286
286
  );
@@ -1,7 +1,5 @@
1
1
  // src/index.ts
2
- import {
3
- createUnplugin
4
- } from "unplugin";
2
+ import { createUnplugin } from "unplugin";
5
3
  import civet from "@danielx/civet";
6
4
  import {
7
5
  remapRange,
@@ -249,7 +247,7 @@ var civetUnplugin = createUnplugin((options = {}) => {
249
247
  }
250
248
  }
251
249
  }
252
- const jsonSourceMap = typeof compiled.sourceMap == "string" ? compiled.sourceMap : compiled.sourceMap.json(
250
+ const jsonSourceMap = typeof compiled.sourceMap == "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
253
251
  path.basename(id.replace(/\.[jt]sx$/, "")),
254
252
  path.basename(id)
255
253
  );
package/dist/unplugin.js CHANGED
@@ -279,7 +279,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
279
279
  }
280
280
  }
281
281
  }
282
- const jsonSourceMap = typeof compiled.sourceMap == "string" ? compiled.sourceMap : compiled.sourceMap.json(
282
+ const jsonSourceMap = typeof compiled.sourceMap == "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
283
283
  import_path.default.basename(id.replace(/\.[jt]sx$/, "")),
284
284
  import_path.default.basename(id)
285
285
  );
package/dist/vite.js CHANGED
@@ -280,7 +280,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
280
280
  }
281
281
  }
282
282
  }
283
- const jsonSourceMap = typeof compiled.sourceMap == "string" ? compiled.sourceMap : compiled.sourceMap.json(
283
+ const jsonSourceMap = typeof compiled.sourceMap == "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
284
284
  import_path.default.basename(id.replace(/\.[jt]sx$/, "")),
285
285
  import_path.default.basename(id)
286
286
  );
package/dist/webpack.js CHANGED
@@ -280,7 +280,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
280
280
  }
281
281
  }
282
282
  }
283
- const jsonSourceMap = typeof compiled.sourceMap == "string" ? compiled.sourceMap : compiled.sourceMap.json(
283
+ const jsonSourceMap = typeof compiled.sourceMap == "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
284
284
  import_path.default.basename(id.replace(/\.[jt]sx$/, "")),
285
285
  import_path.default.basename(id)
286
286
  );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.6.55",
4
+ "version": "0.6.56",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",
@@ -72,6 +72,7 @@
72
72
  "devDependencies": {
73
73
  "@danielx/civet": "0.6.45",
74
74
  "@danielx/hera": "^0.8.10",
75
+ "@prettier/sync": "^0.3.0",
75
76
  "@types/assert": "^1.5.6",
76
77
  "@types/mocha": "^9.1.1",
77
78
  "@types/node": "^20.5.1",
@@ -80,13 +81,13 @@
80
81
  "esbuild": "0.16.17",
81
82
  "marked": "^4.2.4",
82
83
  "mocha": "^10.0.0",
83
- "prettier": "^2.8.1",
84
+ "prettier": "^3.1.1",
84
85
  "terser": "^5.16.1",
85
86
  "ts-node": "^10.9.1",
86
87
  "tslib": "^2.4.0",
87
88
  "tsup": "^7.2.0",
88
89
  "typescript": "^5.2.2",
89
- "vite": "^4.4.9",
90
+ "vite": "^4.4.12",
90
91
  "vitepress": "^1.0.0-alpha.35",
91
92
  "vscode-languageserver": "^8.1.0",
92
93
  "vscode-languageserver-textdocument": "^1.0.8",