devframe 1.2.1 → 1.2.3

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.
@@ -408,7 +408,7 @@ var require_shell_quote = /* @__PURE__ */ __commonJSMin(((exports) => {
408
408
  exports.parse = require_parse();
409
409
  }));
410
410
  //#endregion
411
- //#region ../../node_modules/.pnpm/launch-editor@2.14.1/node_modules/launch-editor/editor-info/macos.js
411
+ //#region ../../node_modules/.pnpm/launch-editor@2.14.2/node_modules/launch-editor/editor-info/macos.js
412
412
  var require_macos = /* @__PURE__ */ __commonJSMin(((exports, module) => {
413
413
  module.exports = {
414
414
  "/Applications/Atom.app/Contents/MacOS/Atom": "atom",
@@ -443,7 +443,7 @@ var require_macos = /* @__PURE__ */ __commonJSMin(((exports, module) => {
443
443
  };
444
444
  }));
445
445
  //#endregion
446
- //#region ../../node_modules/.pnpm/launch-editor@2.14.1/node_modules/launch-editor/editor-info/linux.js
446
+ //#region ../../node_modules/.pnpm/launch-editor@2.14.2/node_modules/launch-editor/editor-info/linux.js
447
447
  var require_linux = /* @__PURE__ */ __commonJSMin(((exports, module) => {
448
448
  module.exports = {
449
449
  atom: "atom",
@@ -477,7 +477,7 @@ var require_linux = /* @__PURE__ */ __commonJSMin(((exports, module) => {
477
477
  };
478
478
  }));
479
479
  //#endregion
480
- //#region ../../node_modules/.pnpm/launch-editor@2.14.1/node_modules/launch-editor/editor-info/windows.js
480
+ //#region ../../node_modules/.pnpm/launch-editor@2.14.2/node_modules/launch-editor/editor-info/windows.js
481
481
  var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
482
482
  module.exports = [
483
483
  "Brackets.exe",
@@ -510,9 +510,9 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
510
510
  ];
511
511
  }));
512
512
  //#endregion
513
- //#region ../../node_modules/.pnpm/launch-editor@2.14.1/node_modules/launch-editor/guess.js
513
+ //#region ../../node_modules/.pnpm/launch-editor@2.14.2/node_modules/launch-editor/guess.js
514
514
  var require_guess = /* @__PURE__ */ __commonJSMin(((exports, module) => {
515
- const path$2 = __require("path");
515
+ const path$3 = __require("path");
516
516
  const shellQuote = require_shell_quote();
517
517
  const childProcess$1 = __require("child_process");
518
518
  const COMMON_EDITORS_MACOS = require_macos();
@@ -536,7 +536,7 @@ var require_guess = /* @__PURE__ */ __commonJSMin(((exports, module) => {
536
536
  const runningProcesses = output.split("\r\n");
537
537
  for (let i = 0; i < runningProcesses.length; i++) {
538
538
  const fullProcessPath = runningProcesses[i].trim();
539
- const shortProcessName = path$2.win32.basename(fullProcessPath);
539
+ const shortProcessName = path$3.win32.basename(fullProcessPath);
540
540
  if (COMMON_EDITORS_WIN.indexOf(shortProcessName) !== -1) return fullProcessPath;
541
541
  }
542
542
  }
@@ -585,11 +585,15 @@ var require_guess = /* @__PURE__ */ __commonJSMin(((exports, module) => {
585
585
  module.exports.getEditorFromLinuxProcesses = getEditorFromLinuxProcesses;
586
586
  }));
587
587
  //#endregion
588
- //#region ../../node_modules/.pnpm/launch-editor@2.14.1/node_modules/launch-editor/get-args.js
588
+ //#region ../../node_modules/.pnpm/launch-editor@2.14.2/node_modules/launch-editor/get-args.js
589
589
  var require_get_args = /* @__PURE__ */ __commonJSMin(((exports, module) => {
590
- const path$1 = __require("path");
591
- module.exports = function getArgumentsForPosition(editor, fileName, lineNumber, columnNumber = 1) {
592
- switch (path$1.basename(editor).replace(/\.(exe|cmd|bat)$/i, "")) {
590
+ const os = __require("os");
591
+ const path$2 = __require("path");
592
+ module.exports = function getArgumentsForFile(editor, fileName, lineNumber, columnNumber = 1) {
593
+ fileName = path$2.resolve(fileName);
594
+ if (process.platform === "linux" && fileName.startsWith("/mnt/") && /Microsoft/i.test(os.release())) fileName = `./${path$2.relative("", fileName)}`;
595
+ if (!lineNumber) return [fileName];
596
+ switch (path$2.basename(editor).replace(/\.(exe|cmd|bat)$/i, "")) {
593
597
  case "atom":
594
598
  case "Atom":
595
599
  case "Atom Beta":
@@ -664,6 +668,41 @@ var require_get_args = /* @__PURE__ */ __commonJSMin(((exports, module) => {
664
668
  };
665
669
  }));
666
670
  //#endregion
671
+ //#region ../../node_modules/.pnpm/launch-editor@2.14.2/node_modules/launch-editor/construct-windows-launch-command.js
672
+ var require_construct_windows_launch_command = /* @__PURE__ */ __commonJSMin(((exports, module) => {
673
+ function escapeCmdArgs(cmdArgs) {
674
+ return cmdArgs.replace(/([&|<>,;=^])/g, "^$1");
675
+ }
676
+ function doubleQuoteIfNeeded(str) {
677
+ if (str.includes("^")) return `^"${str}^"`;
678
+ else if (str.includes(" ")) return `"${str}"`;
679
+ return str;
680
+ }
681
+ function constructWindowsLaunchCommand(editor, args) {
682
+ if (args.some((arg) => /[\r\n]/.test(arg))) throw new Error("Cannot launch an editor with an argument containing a line break");
683
+ if (args.some((arg) => arg.includes("%"))) throw new Error("Cannot launch an editor with an argument containing \"%\"");
684
+ return [editor, ...args.map(escapeCmdArgs)].map(doubleQuoteIfNeeded).join(" ");
685
+ }
686
+ module.exports = constructWindowsLaunchCommand;
687
+ }));
688
+ //#endregion
689
+ //#region ../../node_modules/.pnpm/launch-editor@2.14.2/node_modules/launch-editor/parse-file.js
690
+ var require_parse_file = /* @__PURE__ */ __commonJSMin(((exports, module) => {
691
+ const path$1 = __require("path");
692
+ const positionRE = /:(\d+)(:(\d+))?$/;
693
+ module.exports = function parseFile(file) {
694
+ if (file.startsWith("file://")) file = __require("url").fileURLToPath(file);
695
+ const unresolvedFileName = file.replace(positionRE, "");
696
+ const fileName = unresolvedFileName ? path$1.resolve(unresolvedFileName) : "";
697
+ const match = file.match(positionRE);
698
+ return {
699
+ fileName,
700
+ lineNumber: match && match[1],
701
+ columnNumber: match && match[3]
702
+ };
703
+ };
704
+ }));
705
+ //#endregion
667
706
  //#region src/utils/launch-editor.ts
668
707
  var import_launch_editor = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
669
708
  /**
@@ -676,12 +715,13 @@ var import_launch_editor = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
676
715
  * Modified by Yuxi Evan You
677
716
  */
678
717
  const fs = __require("fs");
679
- const os = __require("os");
680
718
  const path = __require("path");
681
719
  const colors = require_picocolors();
682
720
  const childProcess = __require("child_process");
683
721
  const guessEditor = require_guess();
684
- const getArgumentsForPosition = require_get_args();
722
+ const getArgumentsForFile = require_get_args();
723
+ const constructWindowsLaunchCommand = require_construct_windows_launch_command();
724
+ const parseFile = require_parse_file();
685
725
  function wrapErrorCallback(cb) {
686
726
  return (fileName, errorMessage) => {
687
727
  console.log();
@@ -702,55 +742,36 @@ var import_launch_editor = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
702
742
  }
703
743
  return false;
704
744
  }
705
- const positionRE = /:(\d+)(:(\d+))?$/;
706
- function parseFile(file) {
707
- if (file.startsWith("file://")) file = __require("url").fileURLToPath(file);
708
- const fileName = file.replace(positionRE, "");
709
- const match = file.match(positionRE);
710
- return {
711
- fileName,
712
- lineNumber: match && match[1],
713
- columnNumber: match && match[3]
714
- };
715
- }
716
745
  let currentChildProcess = null;
717
746
  function launchEditor(file, specifiedEditor, onErrorCallback) {
718
- const parsed = parseFile(file);
719
- let { fileName } = parsed;
720
- const { lineNumber, columnNumber } = parsed;
721
- if (process.platform === "win32" && path.resolve(fileName).startsWith("\\\\")) return onErrorCallback(fileName, "UNC paths are not supported on Windows to avoid security issues. See https://github.com/vitejs/launch-editor/tree/main/packages/launch-editor#unc-paths-on-windows for details.");
722
- if (!fs.existsSync(fileName)) return;
747
+ const { fileName, lineNumber, columnNumber } = parseFile(file);
723
748
  if (typeof specifiedEditor === "function") {
724
749
  onErrorCallback = specifiedEditor;
725
750
  specifiedEditor = void 0;
726
751
  }
727
752
  onErrorCallback = wrapErrorCallback(onErrorCallback);
753
+ if (process.platform === "win32" && fileName.startsWith("\\\\")) return onErrorCallback(fileName, "UNC paths are not supported on Windows to avoid security issues. See https://github.com/vitejs/launch-editor/tree/main/packages/launch-editor#unc-paths-on-windows for details.");
754
+ if (!fs.existsSync(fileName)) return;
728
755
  const [editor, ...args] = guessEditor(specifiedEditor);
729
756
  if (!editor) {
730
757
  onErrorCallback(fileName, null);
731
758
  return;
732
759
  }
733
- if (process.platform === "linux" && fileName.startsWith("/mnt/") && /Microsoft/i.test(os.release())) fileName = path.relative("", fileName);
734
- if (lineNumber) {
735
- const extraArgs = getArgumentsForPosition(editor, fileName, lineNumber, columnNumber);
736
- args.push.apply(args, extraArgs);
737
- } else args.push(fileName);
760
+ const extraArgs = getArgumentsForFile(editor, fileName, lineNumber, columnNumber);
761
+ args.push.apply(args, extraArgs);
762
+ let launchCommand;
763
+ if (process.platform === "win32") try {
764
+ launchCommand = constructWindowsLaunchCommand(editor, args);
765
+ } catch (error) {
766
+ onErrorCallback(fileName, error.message);
767
+ return;
768
+ }
738
769
  if (currentChildProcess && isTerminalEditor(editor)) currentChildProcess.kill("SIGKILL");
739
- if (process.platform === "win32") {
740
- function escapeCmdArgs(cmdArgs) {
741
- return cmdArgs.replace(/([&|<>,;=^])/g, "^$1");
742
- }
743
- function doubleQuoteIfNeeded(str) {
744
- if (str.includes("^")) return `^"${str}^"`;
745
- else if (str.includes(" ")) return `"${str}"`;
746
- return str;
747
- }
748
- const launchCommand = [editor, ...args.map(escapeCmdArgs)].map(doubleQuoteIfNeeded).join(" ");
749
- currentChildProcess = childProcess.exec(launchCommand, {
750
- stdio: "inherit",
751
- shell: true
752
- });
753
- } else currentChildProcess = childProcess.spawn(editor, args, { stdio: "inherit" });
770
+ if (process.platform === "win32") currentChildProcess = childProcess.exec(launchCommand, {
771
+ stdio: "inherit",
772
+ shell: true
773
+ });
774
+ else currentChildProcess = childProcess.spawn(editor, args, { stdio: "inherit" });
754
775
  currentChildProcess.on("exit", function(errorCode) {
755
776
  currentChildProcess = null;
756
777
  if (errorCode) onErrorCallback(fileName, "(code " + errorCode + ")");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "devframe",
3
3
  "type": "module",
4
- "version": "1.2.1",
4
+ "version": "1.2.3",
5
5
  "description": "Framework for building one portable devtool integration that runs in any viewer.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -77,7 +77,7 @@
77
77
  "skills"
78
78
  ],
79
79
  "peerDependencies": {
80
- "@devframes/agentic": "1.2.1",
80
+ "@devframes/agentic": "1.2.3",
81
81
  "cac": "^7.0.0"
82
82
  },
83
83
  "peerDependenciesMeta": {
@@ -95,13 +95,13 @@
95
95
  "pathe": "^2.0.3"
96
96
  },
97
97
  "devDependencies": {
98
- "@devframes/agentic": "1.2.1",
98
+ "@devframes/agentic": "1.2.3",
99
99
  "@standard-schema/spec": "^1.1.0",
100
100
  "birpc": "^4.2.0",
101
101
  "cac": "^7.0.0",
102
102
  "get-port-please": "^3.2.0",
103
103
  "immer": "^11.1.21",
104
- "launch-editor": "^2.14.1",
104
+ "launch-editor": "^2.14.2",
105
105
  "mlly": "^1.8.2",
106
106
  "mrmime": "^2.0.1",
107
107
  "obug": "^3.0.0",