@danielx/civet 0.11.5 → 0.11.7

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +306 -0
  2. package/README.md +2 -7
  3. package/dist/babel-plugin.js +7 -6
  4. package/dist/babel-plugin.mjs +3 -3
  5. package/dist/browser.js +807 -540
  6. package/dist/civet +24 -18
  7. package/dist/config.js +7313 -7
  8. package/dist/config.mjs +7338 -4
  9. package/dist/esbuild-plugin.js +7 -6
  10. package/dist/esm.mjs +10 -16
  11. package/dist/main.js +1787 -895
  12. package/dist/main.mjs +1782 -891
  13. package/dist/node-worker.mjs +1 -2
  14. package/dist/ts-diagnostic.js +5 -4
  15. package/dist/ts-diagnostic.mjs +1 -1
  16. package/dist/types.d.ts +11 -2
  17. package/dist/unplugin/astro.js +8 -7
  18. package/dist/unplugin/astro.mjs +6 -4
  19. package/dist/unplugin/esbuild.d.ts +1 -1
  20. package/dist/unplugin/esbuild.js +7 -6
  21. package/dist/unplugin/esbuild.mjs +5 -3
  22. package/dist/unplugin/farm.d.ts +3 -1
  23. package/dist/unplugin/farm.js +7 -6
  24. package/dist/unplugin/farm.mjs +6 -4
  25. package/dist/unplugin/rolldown.d.ts +1 -1
  26. package/dist/unplugin/rolldown.js +7 -6
  27. package/dist/unplugin/rolldown.mjs +5 -3
  28. package/dist/unplugin/rollup.d.ts +1 -1
  29. package/dist/unplugin/rollup.js +7 -6
  30. package/dist/unplugin/rollup.mjs +5 -3
  31. package/dist/unplugin/rspack.d.ts +1 -1
  32. package/dist/unplugin/rspack.js +7 -6
  33. package/dist/unplugin/rspack.mjs +5 -3
  34. package/dist/unplugin/unplugin.d.ts +27 -3
  35. package/dist/unplugin/unplugin.js +68 -42
  36. package/dist/unplugin/unplugin.mjs +53 -30
  37. package/dist/unplugin/vite.d.ts +1 -1
  38. package/dist/unplugin/vite.js +7 -6
  39. package/dist/unplugin/vite.mjs +5 -3
  40. package/dist/unplugin/webpack.d.ts +1 -1
  41. package/dist/unplugin/webpack.js +7 -6
  42. package/dist/unplugin/webpack.mjs +5 -3
  43. package/package.json +33 -17
package/dist/civet CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict"
3
3
  try { require('node:module').enableCompileCache() } catch {}
4
+ "use strict";
4
5
  var __create = Object.create;
5
6
  var __defProp = Object.defineProperty;
6
7
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -29,16 +30,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
30
  ));
30
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
32
 
32
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\cli.civet.jsx
33
- var cli_civet_exports = {};
34
- __export(cli_civet_exports, {
33
+ // source/cli.civet
34
+ var cli_exports = {};
35
+ __export(cli_exports, {
35
36
  cli: () => cli,
36
37
  makeOutputFilename: () => makeOutputFilename,
37
38
  parseArgs: () => parseArgs,
38
39
  repl: () => repl,
39
40
  version: () => version
40
41
  });
41
- module.exports = __toCommonJS(cli_civet_exports);
42
+ module.exports = __toCommonJS(cli_exports);
42
43
  var import_main = require("./main.js");
43
44
  var import_config = require("./config.js");
44
45
  var import_unplugin = require("./unplugin/unplugin.js");
@@ -55,6 +56,7 @@ async function version() {
55
56
  }
56
57
  }
57
58
  var encoding = "utf8";
59
+ var epipeStdoutHandlerInstalled = false;
58
60
  async function parseArgs(args, isTTY = process.stdin.isTTY) {
59
61
  const options = {};
60
62
  const isRun = () => !(options.ast || options.compile || options.typecheck || options.emitDeclaration);
@@ -302,7 +304,7 @@ function makeOutputFilename(filename, options) {
302
304
  ;
303
305
  return;
304
306
  })(ref1), ref1);
305
- return import_node_path.default.format(outputPath);
307
+ return import_node_path.default.normalize(import_node_path.default.format(outputPath));
306
308
  }
307
309
  async function repl(args, options) {
308
310
  const vm = await import("node:vm");
@@ -390,7 +392,7 @@ async function repl(args, options) {
390
392
  } else if (input in ["quit\n", "exit\n", "quit()\n", "exit()\n"]) {
391
393
  return process.exit(0);
392
394
  } else if (input.endsWith("\n\n")) {
393
- let showError = function(error) {
395
+ let showError2 = function(error) {
394
396
  console.error("Error while parsing Civet code:");
395
397
  if ((0, import_main.isCompileError)(error)) {
396
398
  if (error.errors != null) {
@@ -402,12 +404,13 @@ ${" ".repeat(error.column - 1)}^ ${error.header}`);
402
404
  return console.error(error);
403
405
  }
404
406
  };
407
+ var showError = showError2;
405
408
  let output;
406
409
  if (options.compile || options.ast) {
407
410
  try {
408
411
  output = await (0, import_main.compile)(input, { ...options, filename });
409
412
  } catch (error) {
410
- showError(error);
413
+ showError2(error);
411
414
  return callback(null, void 0);
412
415
  }
413
416
  return callback(null, output);
@@ -420,7 +423,7 @@ ${" ".repeat(error.column - 1)}^ ${error.header}`);
420
423
  try {
421
424
  ast = await (0, import_main.compile)(input, { ...options, parseOptions, filename, ast: true });
422
425
  } catch (error) {
423
- showError(error);
426
+ showError2(error);
424
427
  return callback(null, void 0);
425
428
  }
426
429
  let errors = [];
@@ -432,8 +435,8 @@ ${" ".repeat(error.column - 1)}^ ${error.header}`);
432
435
  }
433
436
  if (errors.length) {
434
437
  errors = [];
435
- (0, import_main.generate)(ast, { ...options, errors, sourceMap: new import_main.SourceMap(input) });
436
- showError(errors[0]);
438
+ (0, import_main.generate)(ast, { ...options, errors, sourceMap: new import_main.SourceMap(input, filename) });
439
+ showError2(errors[0]);
437
440
  return callback(null, void 0);
438
441
  }
439
442
  let result;
@@ -601,14 +604,17 @@ You can override this behavior via: --civet rewriteCivetImports=.ext
601
604
  if (options.repl) {
602
605
  return repl(args, options);
603
606
  }
604
- process.stdout.on("error", (e) => {
605
- if (["EPIPE", "EOF"].includes(e.code)) {
606
- return process.exit(0);
607
- } else {
608
- console.error(e);
609
- return process.exit(1);
610
- }
611
- });
607
+ if (!epipeStdoutHandlerInstalled) {
608
+ epipeStdoutHandlerInstalled = true;
609
+ process.stdout.on("error", (e) => {
610
+ if (["EPIPE", "EOF"].includes(e.code)) {
611
+ return process.exit(0);
612
+ } else {
613
+ console.error(e);
614
+ return process.exit(1);
615
+ }
616
+ });
617
+ }
612
618
  let errors = 0;
613
619
  for await (let { filename, error, content, stdin } of readFiles(filenames, options.eval)) {
614
620
  if (error) {