@danielx/civet 0.6.69 → 0.6.70

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
@@ -685,7 +685,7 @@ var Civet = (() => {
685
685
  commaCount ? {
686
686
  type: "ParenthesizedExpression",
687
687
  children: ["(", call, ")"]
688
- } : call
688
+ } : { ...call, type: "ParenthesizedExpression" }
689
689
  );
690
690
  }
691
691
  }
@@ -1958,7 +1958,7 @@ var Civet = (() => {
1958
1958
  children
1959
1959
  };
1960
1960
  }
1961
- function makeGetterMethod(name, ws, value, block, kind = { token: "get" }, autoReturn = true) {
1961
+ function makeGetterMethod(name, ws, value, returnType, block, kind = { token: "get" }, autoReturn = true) {
1962
1962
  const { token } = kind;
1963
1963
  ws = insertTrimmingSpace(ws, "");
1964
1964
  let setVal;
@@ -1989,7 +1989,7 @@ var Civet = (() => {
1989
1989
  const finalStatement = token === "get" ? [[expressions[0]?.[0] || "", ws], wrapWithReturn(value)] : [[expressions[0]?.[0] || "", ws], [value, " = ", setVal]];
1990
1990
  expressions.push(finalStatement);
1991
1991
  }
1992
- const children = [kind, " ", name, parameters, block];
1992
+ const children = [kind, " ", name, parameters, returnType, block];
1993
1993
  return {
1994
1994
  type: "MethodDefinition",
1995
1995
  children,
@@ -2002,7 +2002,7 @@ var Civet = (() => {
2002
2002
  async: false
2003
2003
  },
2004
2004
  name,
2005
- returnType: void 0
2005
+ returnType
2006
2006
  },
2007
2007
  block,
2008
2008
  parameters
@@ -5814,7 +5814,9 @@ ${input.slice(result.pos)}
5814
5814
  }
5815
5815
  var PipelineTailItem$0 = Await;
5816
5816
  var PipelineTailItem$1 = Yield;
5817
- var PipelineTailItem$2 = Return;
5817
+ var PipelineTailItem$2 = $T($S(Return, $N(AccessStart)), function(value) {
5818
+ return value[0];
5819
+ });
5818
5820
  var PipelineTailItem$3 = AmpersandFunctionExpression;
5819
5821
  var PipelineTailItem$4 = $T($S($N(Ampersand), PipelineHeadItem), function(value) {
5820
5822
  return value[1];
@@ -6048,7 +6050,7 @@ ${input.slice(result.pos)}
6048
6050
  var ClassElement$0 = $TS($S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition), function($skip, $loc, $0, $1, $2, $3, $4) {
6049
6051
  var decorators = $1;
6050
6052
  var definition = $4;
6051
- if (definition.type === "ShorthandMethodDefinition") {
6053
+ if (definition.type === "MultiMethodDefinition") {
6052
6054
  return {
6053
6055
  ...definition,
6054
6056
  children: definition.children.map((c) => {
@@ -8411,6 +8413,11 @@ ${input.slice(result.pos)}
8411
8413
  var PropertyDefinition$2 = $TS($S($E(_), MethodDefinition), function($skip, $loc, $0, $1, $2) {
8412
8414
  var ws = $1;
8413
8415
  var def = $2;
8416
+ if (def.type === "MultiMethodDefinition") {
8417
+ return {
8418
+ children: def.children.flatMap((c, i) => i ? [",", c] : [c])
8419
+ };
8420
+ }
8414
8421
  if (!def.block || def.block.empty)
8415
8422
  return $skip;
8416
8423
  return {
@@ -8645,16 +8652,16 @@ ${input.slice(result.pos)}
8645
8652
  parameters: signature.parameters
8646
8653
  };
8647
8654
  });
8648
- var MethodDefinition$2 = $TS($S(GetOrSet, $E(_), ForbidIndentedApplication, $E($S(MemberBase, $Q(CallExpressionRest))), RestoreIndentedApplication, $E(BracedBlock)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
8655
+ var MethodDefinition$2 = $TS($S(GetOrSet, $E(_), ForbidIndentedApplication, $E($S(MemberBase, $Q(CallExpressionRest), $E(ReturnTypeSuffix))), RestoreIndentedApplication, $E(BracedBlock)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
8649
8656
  var kind = $1;
8650
8657
  var ws = $2;
8651
- var value = $4;
8658
+ var content = $4;
8652
8659
  var block = $6;
8653
- if (!value)
8660
+ if (!content)
8654
8661
  return $skip;
8655
- const rest = value[1];
8662
+ const [base, rest, returnType] = content;
8663
+ const value = [base, rest];
8656
8664
  if (!rest.length) {
8657
- const base = value[0];
8658
8665
  let name2;
8659
8666
  if (base.type === "MemberExpression") {
8660
8667
  const lastAccess2 = lastAccessInCallExpression(base);
@@ -8669,7 +8676,7 @@ ${input.slice(result.pos)}
8669
8676
  if (name2[0] === "#")
8670
8677
  name2 = name2.slice(1);
8671
8678
  const autoReturn = !block || base.type !== "Identifier";
8672
- return makeGetterMethod(name2, ws, base, block, kind, autoReturn);
8679
+ return makeGetterMethod(name2, ws, base, returnType, block, kind, autoReturn);
8673
8680
  }
8674
8681
  let last = rest[rest.length - 1];
8675
8682
  while (Array.isArray(last)) {
@@ -8680,10 +8687,10 @@ ${input.slice(result.pos)}
8680
8687
  return $skip;
8681
8688
  case "PropertyAccess":
8682
8689
  const { name: name2 } = last;
8683
- return makeGetterMethod(name2, ws, value, block, kind);
8690
+ return makeGetterMethod(name2, ws, value, returnType, block, kind);
8684
8691
  case "PropertyGlob":
8685
8692
  return {
8686
- type: "ShorthandMethodDefinition",
8693
+ type: "MultiMethodDefinition",
8687
8694
  children: last.object.properties.map((p) => {
8688
8695
  const { name: name3, type } = p;
8689
8696
  let v;
@@ -8697,7 +8704,7 @@ ${input.slice(result.pos)}
8697
8704
  }
8698
8705
  const exp = processCallMemberExpression({
8699
8706
  type: "CallExpression",
8700
- children: [value[0], ...value[1].slice(0, -1), {
8707
+ children: [base, ...rest.slice(0, -1), {
8701
8708
  type: "PropertyAccess",
8702
8709
  children: [last.dot, {
8703
8710
  ...v,
@@ -8706,13 +8713,13 @@ ${input.slice(result.pos)}
8706
8713
  }]
8707
8714
  }]
8708
8715
  });
8709
- return makeGetterMethod(name3, ws, exp, block, kind);
8716
+ return makeGetterMethod(name3, ws, exp, returnType, block, kind);
8710
8717
  })
8711
8718
  };
8712
8719
  }
8713
8720
  const lastAccess = lastAccessInCallExpression({ children: rest });
8714
8721
  const { name } = lastAccess;
8715
- return makeGetterMethod(name, ws, value, block, kind);
8722
+ return makeGetterMethod(name, ws, value, returnType, block, kind);
8716
8723
  });
8717
8724
  var MethodDefinition$$ = [MethodDefinition$0, MethodDefinition$1, MethodDefinition$2];
8718
8725
  function MethodDefinition(ctx, state) {
package/dist/civet CHANGED
@@ -28,15 +28,9 @@ var import_main = require("./main.js");
28
28
  var import_config = require("./config.js");
29
29
  var import_promises = __toESM(require("fs/promises"));
30
30
  var import_path = __toESM(require("path"));
31
- var version;
32
- var parseArgs;
33
- var readFiles;
34
- var repl;
35
- var cli;
36
- var indexOf = [].indexOf;
37
- version = function() {
31
+ function version() {
38
32
  return require("../package.json").version;
39
- };
33
+ }
40
34
  if (process.argv.includes("--version")) {
41
35
  console.log(version());
42
36
  process.exit(0);
@@ -80,37 +74,35 @@ You can use - to read from stdin or (prefixed by -o) write to stdout.
80
74
  process.exit(0);
81
75
  }
82
76
  var encoding = "utf8";
83
- parseArgs = function(args) {
84
- var options, filenames, scriptArgs, i, endOfArgs, arg;
85
- options = {};
77
+ function parseArgs(args) {
78
+ const options = {};
86
79
  Object.defineProperty(options, "run", {
87
80
  get: function() {
88
81
  return !(this.ast || this.compile);
89
82
  }
90
83
  });
91
- filenames = [];
92
- scriptArgs = null;
93
- i = 0;
94
- endOfArgs = function(j) {
84
+ const filenames = [];
85
+ let scriptArgs = [];
86
+ let i = 0;
87
+ function endOfArgs(j) {
95
88
  i = args.length;
96
89
  if (j >= args.length) {
97
90
  return;
98
91
  }
99
92
  if (options.run) {
100
93
  filenames.push(args[j]);
101
- return scriptArgs = args.slice(j + 1);
94
+ scriptArgs = args.slice(j + 1);
102
95
  } else {
103
- return filenames.push(...args.slice(j));
96
+ filenames.push(...args.slice(j));
104
97
  }
105
- };
98
+ }
106
99
  while (i < args.length) {
107
- arg = args[i];
100
+ const arg = args[i];
108
101
  if (/^-\w{2,}$/.test(arg)) {
109
102
  args.splice(i, 1 + i - i, ...(() => {
110
- var char;
111
103
  const results = [];
112
104
  for (let ref = arg.slice(1), i1 = 0, len = ref.length; i1 < len; i1++) {
113
- char = ref[i1];
105
+ const char = ref[i1];
114
106
  results.push(`-${char}`);
115
107
  }
116
108
  return results;
@@ -178,14 +170,14 @@ parseArgs = function(args) {
178
170
  i++;
179
171
  }
180
172
  return { filenames, scriptArgs, options };
181
- };
182
- readFiles = async function* (filenames, options) {
183
- var filename, stdin, lines, rl, content;
173
+ }
174
+ async function* readFiles(filenames) {
184
175
  const results1 = [];
185
176
  for (let i2 = 0, len1 = filenames.length; i2 < len1; i2++) {
186
- filename = filenames[i2];
187
- stdin = filename === "-";
177
+ let filename = filenames[i2];
178
+ const stdin = filename === "-";
188
179
  try {
180
+ let content;
189
181
  if (stdin) {
190
182
  process.stdin.setEncoding(encoding);
191
183
  filename = "<stdin>";
@@ -194,24 +186,21 @@ readFiles = async function* (filenames, options) {
194
186
  } catch (e) {
195
187
  }
196
188
  if (process.stdin.isTTY) {
197
- lines = [];
198
- rl = require("readline").createInterface(process.stdin, process.stdout);
199
- rl.on("line", function(buffer) {
200
- return lines.push(buffer + "\n");
201
- });
202
- content = await new Promise(function(resolve, reject) {
203
- rl.on("SIGINT", function() {
189
+ const lines = [];
190
+ const rl = (await import("readline")).createInterface(process.stdin, process.stdout);
191
+ rl.on("line", (buffer) => lines.push(buffer + "\n"));
192
+ content = await new Promise((resolve, reject) => {
193
+ rl.on("SIGINT", () => {
204
194
  return reject("^C");
205
195
  });
206
- return rl.on("close", function() {
196
+ return rl.on("close", () => {
207
197
  return resolve(lines.join(""));
208
198
  });
209
199
  });
210
200
  } else {
211
201
  content = (await (async () => {
212
- var chunk;
213
202
  const results2 = [];
214
- for await (chunk of process.stdin) {
203
+ for await (const chunk of process.stdin) {
215
204
  results2.push(chunk);
216
205
  }
217
206
  return results2;
@@ -227,9 +216,8 @@ readFiles = async function* (filenames, options) {
227
216
  }
228
217
  ;
229
218
  return results1;
230
- };
231
- repl = function(options) {
232
- var nodeRepl, vm, r;
219
+ }
220
+ async function repl(options) {
233
221
  console.log(`Civet ${version()} REPL. Enter a blank line to ${(() => {
234
222
  switch (false) {
235
223
  case !options.ast: {
@@ -243,12 +231,10 @@ repl = function(options) {
243
231
  }
244
232
  }
245
233
  })()} code.`);
246
- global.quit = global.exit = function() {
247
- return process.exit(0);
248
- };
249
- nodeRepl = require("repl");
250
- vm = require("vm");
251
- return r = nodeRepl.start({
234
+ global.quit = global.exit = () => process.exit(0);
235
+ const nodeRepl = await import("repl");
236
+ const vm = await import("vm");
237
+ const r = nodeRepl.start({
252
238
  prompt: (() => {
253
239
  switch (false) {
254
240
  case !options.ast: {
@@ -262,53 +248,54 @@ repl = function(options) {
262
248
  }
263
249
  }
264
250
  })(),
265
- writer: options.ast ? function(obj) {
251
+ writer: options.ast ? (obj) => {
266
252
  try {
267
253
  return JSON.stringify(obj, null, 2);
268
254
  } catch (e) {
269
255
  console.log(`Failed to stringify: ${e}`);
270
- return obj;
256
+ return "";
271
257
  }
272
- } : options.compile ? function(obj) {
258
+ } : options.compile ? (obj) => {
273
259
  if (typeof obj === "string") {
274
260
  return obj?.replace(/\n*$/, "");
275
261
  } else {
276
- return obj;
262
+ return "";
277
263
  }
278
264
  } : void 0,
279
265
  eval: function(input, context, filename, callback) {
280
- var output, result;
281
266
  if (input === "\n") {
282
- return callback(null);
283
- } else if (indexOf.call(["quit\n", "exit\n", "quit()\n", "exit()\n"], input) >= 0) {
267
+ return callback(null, void 0);
268
+ } else if (input in ["quit\n", "exit\n", "quit()\n", "exit()\n"]) {
284
269
  return process.exit(0);
285
270
  } else if (input.endsWith("\n\n")) {
271
+ let output;
286
272
  try {
287
273
  output = (0, import_main.compile)(input, { ...options, filename });
288
274
  } catch (error) {
289
275
  console.error(error);
290
- return callback("");
276
+ return callback(null, void 0);
291
277
  }
292
278
  if (options.compile || options.ast) {
293
279
  return callback(null, output);
294
280
  } else {
281
+ let result;
295
282
  try {
296
283
  result = vm.runInContext(output, context, { filename });
297
284
  } catch (error) {
298
- return callback(error);
285
+ return callback(error, void 0);
299
286
  }
300
287
  return callback(null, result);
301
288
  }
302
289
  } else {
303
- return callback(new nodeRepl.Recoverable("Enter a blank line to execute code."));
290
+ return callback(new nodeRepl.Recoverable(new Error("Enter a blank line to execute code.")), null);
304
291
  }
305
292
  }
306
293
  });
307
- };
308
- cli = async function() {
309
- var argv, filenames, scriptArgs, options, filename, error, content, stdin, output, outputPath, outputFilename, optionsPath, stat, esm, execArgv, debugRe, isDebug, child;
310
- argv = process.argv;
311
- ({ filenames, scriptArgs, options } = parseArgs(argv.slice(2)));
294
+ return r;
295
+ }
296
+ async function cli() {
297
+ const argv = process.argv;
298
+ let { filenames, scriptArgs, options } = parseArgs(argv.slice(2));
312
299
  if (options.config !== false) {
313
300
  options.config ??= await (0, import_config.findConfig)(process.cwd());
314
301
  }
@@ -334,12 +321,13 @@ cli = async function() {
334
321
  return repl(options);
335
322
  }
336
323
  const results3 = [];
337
- for await ({ filename, error, content, stdin } of readFiles(filenames, options)) {
324
+ for await (const { filename, error, content, stdin } of readFiles(filenames)) {
338
325
  if (error) {
339
326
  console.error(`${filename} failed to load:`);
340
327
  console.error(error);
341
328
  continue;
342
329
  }
330
+ let output;
343
331
  try {
344
332
  output = (0, import_main.compile)(content, { ...options, filename });
345
333
  } catch (error2) {
@@ -352,7 +340,7 @@ cli = async function() {
352
340
  if (stdin && !options.output || options.output === "-") {
353
341
  results3.push(process.stdout.write(output));
354
342
  } else {
355
- outputPath = import_path.default.parse(filename);
343
+ let outputPath = import_path.default.parse(filename);
356
344
  delete outputPath.base;
357
345
  if (options.js) {
358
346
  outputPath.ext += ".jsx";
@@ -360,7 +348,8 @@ cli = async function() {
360
348
  outputPath.ext += ".tsx";
361
349
  }
362
350
  if (options.output) {
363
- optionsPath = import_path.default.parse(options.output);
351
+ const optionsPath = import_path.default.parse(options.output);
352
+ let stat;
364
353
  try {
365
354
  stat = await import_promises.default.stat(options.output);
366
355
  } catch {
@@ -380,7 +369,7 @@ cli = async function() {
380
369
  if (outputPath.dir) {
381
370
  import_promises.default.mkdir(outputPath.dir, { recursive: true });
382
371
  }
383
- outputFilename = import_path.default.format(outputPath);
372
+ const outputFilename = import_path.default.format(outputPath);
384
373
  try {
385
374
  results3.push(await import_promises.default.writeFile(outputFilename, output));
386
375
  } catch (error2) {
@@ -389,35 +378,35 @@ cli = async function() {
389
378
  }
390
379
  }
391
380
  } else {
392
- esm = /^\s*(import|export)\b/m.test(output);
381
+ const esm = /^\s*(import|export)\b/m.test(output);
393
382
  if (esm) {
394
383
  if (stdin) {
395
- filename = `.stdin-${process.pid}.civet`;
384
+ const filename2 = `.stdin-${process.pid}.civet`;
396
385
  try {
397
- await import_promises.default.writeFile(filename, content, { encoding });
386
+ await import_promises.default.writeFile(filename2, content, { encoding });
398
387
  } catch (e) {
399
- console.error(`Could not write ${filename} for Civet ESM mode:`);
388
+ console.error(`Could not write ${filename2} for Civet ESM mode:`);
400
389
  console.error(e);
401
390
  process.exit(1);
402
391
  }
403
392
  }
404
393
  const { fork } = await import("child_process");
405
- execArgv = ["--loader", "@danielx/civet/esm"];
406
- debugRe = /--debug|--inspect/;
407
- isDebug = typeof v8debug === "object" || debugRe.test(process.execArgv.join(" ")) || debugRe.test(process.env.NODE_OPTIONS);
394
+ const execArgv = ["--loader", "@danielx/civet/esm"];
395
+ const debugRe = /--debug|--inspect/;
396
+ const isDebug = typeof v8debug === "object" || debugRe.test(process.execArgv.join(" ")) || debugRe.test(process.env.NODE_OPTIONS ?? "");
408
397
  if (process.env.NODE_OPTIONS) {
409
398
  execArgv.push(process.env.NODE_OPTIONS);
410
399
  }
411
400
  if (isDebug) {
412
401
  execArgv.push("--inspect=" + (process.debugPort + 1));
413
402
  }
414
- child = fork(filename, [
403
+ const child = fork(filename, [
415
404
  ...scriptArgs
416
405
  ], {
417
406
  execArgv,
418
407
  stdio: "inherit"
419
408
  });
420
- results3.push(child.on("exit", async function(code) {
409
+ results3.push(child.on("exit", async (code) => {
421
410
  if (stdin) {
422
411
  await import_promises.default.unlink(filename);
423
412
  }
@@ -444,7 +433,7 @@ cli = async function() {
444
433
  }
445
434
  ;
446
435
  return results3;
447
- };
436
+ }
448
437
  if (require.main === module) {
449
438
  cli();
450
439
  }
package/dist/main.js CHANGED
@@ -677,7 +677,7 @@ function processCallMemberExpression(node) {
677
677
  commaCount ? {
678
678
  type: "ParenthesizedExpression",
679
679
  children: ["(", call, ")"]
680
- } : call
680
+ } : { ...call, type: "ParenthesizedExpression" }
681
681
  );
682
682
  }
683
683
  }
@@ -1950,7 +1950,7 @@ function duplicateBlock(block) {
1950
1950
  children
1951
1951
  };
1952
1952
  }
1953
- function makeGetterMethod(name, ws, value, block, kind = { token: "get" }, autoReturn = true) {
1953
+ function makeGetterMethod(name, ws, value, returnType, block, kind = { token: "get" }, autoReturn = true) {
1954
1954
  const { token } = kind;
1955
1955
  ws = insertTrimmingSpace(ws, "");
1956
1956
  let setVal;
@@ -1981,7 +1981,7 @@ function makeGetterMethod(name, ws, value, block, kind = { token: "get" }, autoR
1981
1981
  const finalStatement = token === "get" ? [[expressions[0]?.[0] || "", ws], wrapWithReturn(value)] : [[expressions[0]?.[0] || "", ws], [value, " = ", setVal]];
1982
1982
  expressions.push(finalStatement);
1983
1983
  }
1984
- const children = [kind, " ", name, parameters, block];
1984
+ const children = [kind, " ", name, parameters, returnType, block];
1985
1985
  return {
1986
1986
  type: "MethodDefinition",
1987
1987
  children,
@@ -1994,7 +1994,7 @@ function makeGetterMethod(name, ws, value, block, kind = { token: "get" }, autoR
1994
1994
  async: false
1995
1995
  },
1996
1996
  name,
1997
- returnType: void 0
1997
+ returnType
1998
1998
  },
1999
1999
  block,
2000
2000
  parameters
@@ -5806,7 +5806,9 @@ var require_parser = __commonJS({
5806
5806
  }
5807
5807
  var PipelineTailItem$0 = Await;
5808
5808
  var PipelineTailItem$1 = Yield;
5809
- var PipelineTailItem$2 = Return;
5809
+ var PipelineTailItem$2 = $T($S(Return, $N(AccessStart)), function(value) {
5810
+ return value[0];
5811
+ });
5810
5812
  var PipelineTailItem$3 = AmpersandFunctionExpression;
5811
5813
  var PipelineTailItem$4 = $T($S($N(Ampersand), PipelineHeadItem), function(value) {
5812
5814
  return value[1];
@@ -6040,7 +6042,7 @@ var require_parser = __commonJS({
6040
6042
  var ClassElement$0 = $TS($S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition), function($skip, $loc, $0, $1, $2, $3, $4) {
6041
6043
  var decorators = $1;
6042
6044
  var definition = $4;
6043
- if (definition.type === "ShorthandMethodDefinition") {
6045
+ if (definition.type === "MultiMethodDefinition") {
6044
6046
  return {
6045
6047
  ...definition,
6046
6048
  children: definition.children.map((c) => {
@@ -8403,6 +8405,11 @@ var require_parser = __commonJS({
8403
8405
  var PropertyDefinition$2 = $TS($S($E(_), MethodDefinition), function($skip, $loc, $0, $1, $2) {
8404
8406
  var ws = $1;
8405
8407
  var def = $2;
8408
+ if (def.type === "MultiMethodDefinition") {
8409
+ return {
8410
+ children: def.children.flatMap((c, i) => i ? [",", c] : [c])
8411
+ };
8412
+ }
8406
8413
  if (!def.block || def.block.empty)
8407
8414
  return $skip;
8408
8415
  return {
@@ -8637,16 +8644,16 @@ var require_parser = __commonJS({
8637
8644
  parameters: signature.parameters
8638
8645
  };
8639
8646
  });
8640
- var MethodDefinition$2 = $TS($S(GetOrSet, $E(_), ForbidIndentedApplication, $E($S(MemberBase, $Q(CallExpressionRest))), RestoreIndentedApplication, $E(BracedBlock)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
8647
+ var MethodDefinition$2 = $TS($S(GetOrSet, $E(_), ForbidIndentedApplication, $E($S(MemberBase, $Q(CallExpressionRest), $E(ReturnTypeSuffix))), RestoreIndentedApplication, $E(BracedBlock)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
8641
8648
  var kind = $1;
8642
8649
  var ws = $2;
8643
- var value = $4;
8650
+ var content = $4;
8644
8651
  var block = $6;
8645
- if (!value)
8652
+ if (!content)
8646
8653
  return $skip;
8647
- const rest = value[1];
8654
+ const [base, rest, returnType] = content;
8655
+ const value = [base, rest];
8648
8656
  if (!rest.length) {
8649
- const base = value[0];
8650
8657
  let name2;
8651
8658
  if (base.type === "MemberExpression") {
8652
8659
  const lastAccess2 = lastAccessInCallExpression(base);
@@ -8661,7 +8668,7 @@ var require_parser = __commonJS({
8661
8668
  if (name2[0] === "#")
8662
8669
  name2 = name2.slice(1);
8663
8670
  const autoReturn = !block || base.type !== "Identifier";
8664
- return makeGetterMethod(name2, ws, base, block, kind, autoReturn);
8671
+ return makeGetterMethod(name2, ws, base, returnType, block, kind, autoReturn);
8665
8672
  }
8666
8673
  let last = rest[rest.length - 1];
8667
8674
  while (Array.isArray(last)) {
@@ -8672,10 +8679,10 @@ var require_parser = __commonJS({
8672
8679
  return $skip;
8673
8680
  case "PropertyAccess":
8674
8681
  const { name: name2 } = last;
8675
- return makeGetterMethod(name2, ws, value, block, kind);
8682
+ return makeGetterMethod(name2, ws, value, returnType, block, kind);
8676
8683
  case "PropertyGlob":
8677
8684
  return {
8678
- type: "ShorthandMethodDefinition",
8685
+ type: "MultiMethodDefinition",
8679
8686
  children: last.object.properties.map((p) => {
8680
8687
  const { name: name3, type } = p;
8681
8688
  let v;
@@ -8689,7 +8696,7 @@ var require_parser = __commonJS({
8689
8696
  }
8690
8697
  const exp = processCallMemberExpression({
8691
8698
  type: "CallExpression",
8692
- children: [value[0], ...value[1].slice(0, -1), {
8699
+ children: [base, ...rest.slice(0, -1), {
8693
8700
  type: "PropertyAccess",
8694
8701
  children: [last.dot, {
8695
8702
  ...v,
@@ -8698,13 +8705,13 @@ var require_parser = __commonJS({
8698
8705
  }]
8699
8706
  }]
8700
8707
  });
8701
- return makeGetterMethod(name3, ws, exp, block, kind);
8708
+ return makeGetterMethod(name3, ws, exp, returnType, block, kind);
8702
8709
  })
8703
8710
  };
8704
8711
  }
8705
8712
  const lastAccess = lastAccessInCallExpression({ children: rest });
8706
8713
  const { name } = lastAccess;
8707
- return makeGetterMethod(name, ws, value, block, kind);
8714
+ return makeGetterMethod(name, ws, value, returnType, block, kind);
8708
8715
  });
8709
8716
  var MethodDefinition$$ = [MethodDefinition$0, MethodDefinition$1, MethodDefinition$2];
8710
8717
  function MethodDefinition(ctx, state) {
package/dist/main.mjs CHANGED
@@ -675,7 +675,7 @@ function processCallMemberExpression(node) {
675
675
  commaCount ? {
676
676
  type: "ParenthesizedExpression",
677
677
  children: ["(", call, ")"]
678
- } : call
678
+ } : { ...call, type: "ParenthesizedExpression" }
679
679
  );
680
680
  }
681
681
  }
@@ -1948,7 +1948,7 @@ function duplicateBlock(block) {
1948
1948
  children
1949
1949
  };
1950
1950
  }
1951
- function makeGetterMethod(name, ws, value, block, kind = { token: "get" }, autoReturn = true) {
1951
+ function makeGetterMethod(name, ws, value, returnType, block, kind = { token: "get" }, autoReturn = true) {
1952
1952
  const { token } = kind;
1953
1953
  ws = insertTrimmingSpace(ws, "");
1954
1954
  let setVal;
@@ -1979,7 +1979,7 @@ function makeGetterMethod(name, ws, value, block, kind = { token: "get" }, autoR
1979
1979
  const finalStatement = token === "get" ? [[expressions[0]?.[0] || "", ws], wrapWithReturn(value)] : [[expressions[0]?.[0] || "", ws], [value, " = ", setVal]];
1980
1980
  expressions.push(finalStatement);
1981
1981
  }
1982
- const children = [kind, " ", name, parameters, block];
1982
+ const children = [kind, " ", name, parameters, returnType, block];
1983
1983
  return {
1984
1984
  type: "MethodDefinition",
1985
1985
  children,
@@ -1992,7 +1992,7 @@ function makeGetterMethod(name, ws, value, block, kind = { token: "get" }, autoR
1992
1992
  async: false
1993
1993
  },
1994
1994
  name,
1995
- returnType: void 0
1995
+ returnType
1996
1996
  },
1997
1997
  block,
1998
1998
  parameters
@@ -5804,7 +5804,9 @@ var require_parser = __commonJS({
5804
5804
  }
5805
5805
  var PipelineTailItem$0 = Await;
5806
5806
  var PipelineTailItem$1 = Yield;
5807
- var PipelineTailItem$2 = Return;
5807
+ var PipelineTailItem$2 = $T($S(Return, $N(AccessStart)), function(value) {
5808
+ return value[0];
5809
+ });
5808
5810
  var PipelineTailItem$3 = AmpersandFunctionExpression;
5809
5811
  var PipelineTailItem$4 = $T($S($N(Ampersand), PipelineHeadItem), function(value) {
5810
5812
  return value[1];
@@ -6038,7 +6040,7 @@ var require_parser = __commonJS({
6038
6040
  var ClassElement$0 = $TS($S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition), function($skip, $loc, $0, $1, $2, $3, $4) {
6039
6041
  var decorators = $1;
6040
6042
  var definition = $4;
6041
- if (definition.type === "ShorthandMethodDefinition") {
6043
+ if (definition.type === "MultiMethodDefinition") {
6042
6044
  return {
6043
6045
  ...definition,
6044
6046
  children: definition.children.map((c) => {
@@ -8401,6 +8403,11 @@ var require_parser = __commonJS({
8401
8403
  var PropertyDefinition$2 = $TS($S($E(_), MethodDefinition), function($skip, $loc, $0, $1, $2) {
8402
8404
  var ws = $1;
8403
8405
  var def = $2;
8406
+ if (def.type === "MultiMethodDefinition") {
8407
+ return {
8408
+ children: def.children.flatMap((c, i) => i ? [",", c] : [c])
8409
+ };
8410
+ }
8404
8411
  if (!def.block || def.block.empty)
8405
8412
  return $skip;
8406
8413
  return {
@@ -8635,16 +8642,16 @@ var require_parser = __commonJS({
8635
8642
  parameters: signature.parameters
8636
8643
  };
8637
8644
  });
8638
- var MethodDefinition$2 = $TS($S(GetOrSet, $E(_), ForbidIndentedApplication, $E($S(MemberBase, $Q(CallExpressionRest))), RestoreIndentedApplication, $E(BracedBlock)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
8645
+ var MethodDefinition$2 = $TS($S(GetOrSet, $E(_), ForbidIndentedApplication, $E($S(MemberBase, $Q(CallExpressionRest), $E(ReturnTypeSuffix))), RestoreIndentedApplication, $E(BracedBlock)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
8639
8646
  var kind = $1;
8640
8647
  var ws = $2;
8641
- var value = $4;
8648
+ var content = $4;
8642
8649
  var block = $6;
8643
- if (!value)
8650
+ if (!content)
8644
8651
  return $skip;
8645
- const rest = value[1];
8652
+ const [base, rest, returnType] = content;
8653
+ const value = [base, rest];
8646
8654
  if (!rest.length) {
8647
- const base = value[0];
8648
8655
  let name2;
8649
8656
  if (base.type === "MemberExpression") {
8650
8657
  const lastAccess2 = lastAccessInCallExpression(base);
@@ -8659,7 +8666,7 @@ var require_parser = __commonJS({
8659
8666
  if (name2[0] === "#")
8660
8667
  name2 = name2.slice(1);
8661
8668
  const autoReturn = !block || base.type !== "Identifier";
8662
- return makeGetterMethod(name2, ws, base, block, kind, autoReturn);
8669
+ return makeGetterMethod(name2, ws, base, returnType, block, kind, autoReturn);
8663
8670
  }
8664
8671
  let last = rest[rest.length - 1];
8665
8672
  while (Array.isArray(last)) {
@@ -8670,10 +8677,10 @@ var require_parser = __commonJS({
8670
8677
  return $skip;
8671
8678
  case "PropertyAccess":
8672
8679
  const { name: name2 } = last;
8673
- return makeGetterMethod(name2, ws, value, block, kind);
8680
+ return makeGetterMethod(name2, ws, value, returnType, block, kind);
8674
8681
  case "PropertyGlob":
8675
8682
  return {
8676
- type: "ShorthandMethodDefinition",
8683
+ type: "MultiMethodDefinition",
8677
8684
  children: last.object.properties.map((p) => {
8678
8685
  const { name: name3, type } = p;
8679
8686
  let v;
@@ -8687,7 +8694,7 @@ var require_parser = __commonJS({
8687
8694
  }
8688
8695
  const exp = processCallMemberExpression({
8689
8696
  type: "CallExpression",
8690
- children: [value[0], ...value[1].slice(0, -1), {
8697
+ children: [base, ...rest.slice(0, -1), {
8691
8698
  type: "PropertyAccess",
8692
8699
  children: [last.dot, {
8693
8700
  ...v,
@@ -8696,13 +8703,13 @@ var require_parser = __commonJS({
8696
8703
  }]
8697
8704
  }]
8698
8705
  });
8699
- return makeGetterMethod(name3, ws, exp, block, kind);
8706
+ return makeGetterMethod(name3, ws, exp, returnType, block, kind);
8700
8707
  })
8701
8708
  };
8702
8709
  }
8703
8710
  const lastAccess = lastAccessInCallExpression({ children: rest });
8704
8711
  const { name } = lastAccess;
8705
- return makeGetterMethod(name, ws, value, block, kind);
8712
+ return makeGetterMethod(name, ws, value, returnType, block, kind);
8706
8713
  });
8707
8714
  var MethodDefinition$$ = [MethodDefinition$0, MethodDefinition$1, MethodDefinition$2];
8708
8715
  function MethodDefinition(ctx, state) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.6.69",
4
+ "version": "0.6.70",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",