@maizzle/framework 6.1.3 → 6.1.5

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 (204) hide show
  1. package/dist/build.d.ts +3 -4
  2. package/dist/build.d.ts.map +1 -1
  3. package/dist/build.js +1 -5
  4. package/dist/build.js.map +1 -1
  5. package/dist/components/Outlook.vue +8 -2
  6. package/dist/components/utils.d.ts +10 -11
  7. package/dist/components/utils.d.ts.map +1 -1
  8. package/dist/composables/defineConfig.d.ts +1 -2
  9. package/dist/composables/defineConfig.d.ts.map +1 -1
  10. package/dist/composables/renderContext.d.ts +4 -5
  11. package/dist/composables/renderContext.d.ts.map +1 -1
  12. package/dist/composables/useBaseUrl.d.ts +1 -2
  13. package/dist/composables/useBaseUrl.d.ts.map +1 -1
  14. package/dist/composables/useConfig.d.ts +2 -3
  15. package/dist/composables/useConfig.d.ts.map +1 -1
  16. package/dist/composables/useCurrentTemplate.d.ts +2 -3
  17. package/dist/composables/useCurrentTemplate.d.ts.map +1 -1
  18. package/dist/composables/useDoctype.d.ts +1 -2
  19. package/dist/composables/useDoctype.d.ts.map +1 -1
  20. package/dist/composables/useEvent.d.ts +1 -2
  21. package/dist/composables/useEvent.d.ts.map +1 -1
  22. package/dist/composables/useFont.d.ts +3 -4
  23. package/dist/composables/useFont.d.ts.map +1 -1
  24. package/dist/composables/useOutlookFallback.d.ts +1 -2
  25. package/dist/composables/useOutlookFallback.d.ts.map +1 -1
  26. package/dist/composables/useOutputPath.d.ts +1 -2
  27. package/dist/composables/useOutputPath.d.ts.map +1 -1
  28. package/dist/composables/usePlaintext.d.ts +2 -3
  29. package/dist/composables/usePlaintext.d.ts.map +1 -1
  30. package/dist/composables/usePreheader.d.ts +2 -3
  31. package/dist/composables/usePreheader.d.ts.map +1 -1
  32. package/dist/composables/useTransformers.d.ts +1 -2
  33. package/dist/composables/useTransformers.d.ts.map +1 -1
  34. package/dist/composables/useUrlQuery.d.ts +1 -2
  35. package/dist/composables/useUrlQuery.d.ts.map +1 -1
  36. package/dist/config/defaults.d.ts +1 -2
  37. package/dist/config/defaults.d.ts.map +1 -1
  38. package/dist/config/index.d.ts +4 -4
  39. package/dist/config/index.d.ts.map +1 -1
  40. package/dist/events/index.d.ts +4 -5
  41. package/dist/events/index.d.ts.map +1 -1
  42. package/dist/plaintext.d.ts +1 -2
  43. package/dist/plaintext.d.ts.map +1 -1
  44. package/dist/plugin.d.ts +1 -2
  45. package/dist/plugin.d.ts.map +1 -1
  46. package/dist/plugins/postcss/flattenGradients.d.ts +3 -3
  47. package/dist/plugins/postcss/flattenGradients.d.ts.map +1 -1
  48. package/dist/plugins/postcss/mergeMediaQueries.d.ts +1 -2
  49. package/dist/plugins/postcss/mergeMediaQueries.d.ts.map +1 -1
  50. package/dist/plugins/postcss/pruneVars.d.ts +2 -2
  51. package/dist/plugins/postcss/pruneVars.d.ts.map +1 -1
  52. package/dist/plugins/postcss/quoteFontFamilies.d.ts +2 -3
  53. package/dist/plugins/postcss/quoteFontFamilies.d.ts.map +1 -1
  54. package/dist/plugins/postcss/removeDeclarations.d.ts +4 -4
  55. package/dist/plugins/postcss/removeDeclarations.d.ts.map +1 -1
  56. package/dist/plugins/postcss/resolveMaizzleImports.d.ts +1 -2
  57. package/dist/plugins/postcss/resolveMaizzleImports.d.ts.map +1 -1
  58. package/dist/plugins/postcss/resolveProps.d.ts +2 -2
  59. package/dist/plugins/postcss/resolveProps.d.ts.map +1 -1
  60. package/dist/plugins/postcss/tailwindCleanup.d.ts +1 -2
  61. package/dist/plugins/postcss/tailwindCleanup.d.ts.map +1 -1
  62. package/dist/prepare.d.ts +2 -3
  63. package/dist/prepare.d.ts.map +1 -1
  64. package/dist/render/active.d.ts +2 -3
  65. package/dist/render/active.d.ts.map +1 -1
  66. package/dist/render/buildTemplate.d.ts +5 -6
  67. package/dist/render/buildTemplate.d.ts.map +1 -1
  68. package/dist/render/buildTemplate.js +1 -1
  69. package/dist/render/buildTemplate.js.map +1 -1
  70. package/dist/render/createRenderer.d.ts +4 -5
  71. package/dist/render/createRenderer.d.ts.map +1 -1
  72. package/dist/render/index.d.ts +3 -3
  73. package/dist/render/index.d.ts.map +1 -1
  74. package/dist/render/index.js +1 -1
  75. package/dist/render/index.js.map +1 -1
  76. package/dist/render/injectFonts.d.ts +1 -2
  77. package/dist/render/injectFonts.d.ts.map +1 -1
  78. package/dist/render/parallel/buildWorker.d.ts +3 -4
  79. package/dist/render/parallel/buildWorker.d.ts.map +1 -1
  80. package/dist/render/plugins/codeBlockExtract.d.ts +1 -2
  81. package/dist/render/plugins/codeBlockExtract.d.ts.map +1 -1
  82. package/dist/render/plugins/markdownExtract.d.ts +1 -2
  83. package/dist/render/plugins/markdownExtract.d.ts.map +1 -1
  84. package/dist/render/plugins/rawExtract.d.ts +1 -2
  85. package/dist/render/plugins/rawExtract.d.ts.map +1 -1
  86. package/dist/render/plugins/rowSourceLocation.d.ts +1 -2
  87. package/dist/render/plugins/rowSourceLocation.d.ts.map +1 -1
  88. package/dist/serve.d.ts +3 -4
  89. package/dist/serve.d.ts.map +1 -1
  90. package/dist/serve.js +47 -4
  91. package/dist/serve.js.map +1 -1
  92. package/dist/server/compatibility.d.ts +2 -3
  93. package/dist/server/compatibility.d.ts.map +1 -1
  94. package/dist/server/email.d.ts +2 -3
  95. package/dist/server/email.d.ts.map +1 -1
  96. package/dist/server/linter.d.ts +3 -4
  97. package/dist/server/linter.d.ts.map +1 -1
  98. package/dist/server/sfc-utils.d.ts +6 -7
  99. package/dist/server/sfc-utils.d.ts.map +1 -1
  100. package/dist/server/static.d.ts +10 -0
  101. package/dist/server/static.d.ts.map +1 -0
  102. package/dist/server/static.js +71 -0
  103. package/dist/server/static.js.map +1 -0
  104. package/dist/server/ui/.vite/deps/@lucide_vue.js +1 -1
  105. package/dist/server/ui/.vite/deps/@vueuse_core.js +1 -1
  106. package/dist/server/ui/.vite/deps/@vueuse_shared.js +1 -1
  107. package/dist/server/ui/.vite/deps/_metadata.json +15 -15
  108. package/dist/server/ui/.vite/deps/reka-ui.js +1 -2
  109. package/dist/server/ui/.vite/deps/reka-ui.js.map +1 -1
  110. package/dist/server/ui/.vite/deps/vue-router.js +1 -1
  111. package/dist/server/ui/.vite/deps/vue.js +1 -1
  112. package/dist/server/ui/.vite/deps/{vue.runtime.esm-bundler-S54atuNJ.js → vue.runtime.esm-bundler-Dq07uCLt.js} +174 -53
  113. package/dist/server/ui/.vite/deps/vue.runtime.esm-bundler-Dq07uCLt.js.map +1 -0
  114. package/dist/tests/render/_helpers.d.ts +2 -3
  115. package/dist/tests/render/_helpers.d.ts.map +1 -1
  116. package/dist/transformers/addAttributes.d.ts +2 -3
  117. package/dist/transformers/addAttributes.d.ts.map +1 -1
  118. package/dist/transformers/attributeToStyle.d.ts +2 -3
  119. package/dist/transformers/attributeToStyle.d.ts.map +1 -1
  120. package/dist/transformers/base.d.ts +3 -4
  121. package/dist/transformers/base.d.ts.map +1 -1
  122. package/dist/transformers/columnWidth.d.ts +1 -2
  123. package/dist/transformers/columnWidth.d.ts.map +1 -1
  124. package/dist/transformers/entities.d.ts +3 -4
  125. package/dist/transformers/entities.d.ts.map +1 -1
  126. package/dist/transformers/filters/defaults.d.ts +2 -3
  127. package/dist/transformers/filters/defaults.d.ts.map +1 -1
  128. package/dist/transformers/filters/index.d.ts +4 -4
  129. package/dist/transformers/filters/index.d.ts.map +1 -1
  130. package/dist/transformers/format.d.ts +2 -2
  131. package/dist/transformers/format.d.ts.map +1 -1
  132. package/dist/transformers/imgWidth.d.ts +1 -2
  133. package/dist/transformers/imgWidth.d.ts.map +1 -1
  134. package/dist/transformers/index.d.ts +2 -2
  135. package/dist/transformers/index.d.ts.map +1 -1
  136. package/dist/transformers/index.js +8 -2
  137. package/dist/transformers/index.js.map +1 -1
  138. package/dist/transformers/inlineCss.d.ts +3 -4
  139. package/dist/transformers/inlineCss.d.ts.map +1 -1
  140. package/dist/transformers/inlineLink.d.ts +2 -3
  141. package/dist/transformers/inlineLink.d.ts.map +1 -1
  142. package/dist/transformers/minify.d.ts +2 -2
  143. package/dist/transformers/minify.d.ts.map +1 -1
  144. package/dist/transformers/minifyCodeInline.d.ts +1 -2
  145. package/dist/transformers/minifyCodeInline.d.ts.map +1 -1
  146. package/dist/transformers/msoConditionals.d.ts +4 -0
  147. package/dist/transformers/msoConditionals.d.ts.map +1 -0
  148. package/dist/transformers/msoConditionals.js +25 -0
  149. package/dist/transformers/msoConditionals.js.map +1 -0
  150. package/dist/transformers/msoPlaceholders.d.ts +1 -2
  151. package/dist/transformers/msoPlaceholders.d.ts.map +1 -1
  152. package/dist/transformers/purgeCss.d.ts +3 -4
  153. package/dist/transformers/purgeCss.d.ts.map +1 -1
  154. package/dist/transformers/removeAttributes.d.ts +4 -5
  155. package/dist/transformers/removeAttributes.d.ts.map +1 -1
  156. package/dist/transformers/replaceStrings.d.ts +1 -2
  157. package/dist/transformers/replaceStrings.d.ts.map +1 -1
  158. package/dist/transformers/safeSelectors.d.ts +2 -3
  159. package/dist/transformers/safeSelectors.d.ts.map +1 -1
  160. package/dist/transformers/shorthandCss.d.ts +3 -4
  161. package/dist/transformers/shorthandCss.d.ts.map +1 -1
  162. package/dist/transformers/sixHex.d.ts +2 -3
  163. package/dist/transformers/sixHex.d.ts.map +1 -1
  164. package/dist/transformers/tailwindComponent.d.ts +1 -2
  165. package/dist/transformers/tailwindComponent.d.ts.map +1 -1
  166. package/dist/transformers/tailwindcss.d.ts +2 -3
  167. package/dist/transformers/tailwindcss.d.ts.map +1 -1
  168. package/dist/transformers/urlQuery.d.ts +2 -3
  169. package/dist/transformers/urlQuery.d.ts.map +1 -1
  170. package/dist/types/config.d.ts +18 -19
  171. package/dist/types/config.d.ts.map +1 -1
  172. package/dist/utils/ast/parser.d.ts +1 -2
  173. package/dist/utils/ast/parser.d.ts.map +1 -1
  174. package/dist/utils/ast/serializer.d.ts +1 -2
  175. package/dist/utils/ast/serializer.d.ts.map +1 -1
  176. package/dist/utils/ast/walker.d.ts +1 -2
  177. package/dist/utils/ast/walker.d.ts.map +1 -1
  178. package/dist/utils/cloneConfig.d.ts +1 -2
  179. package/dist/utils/cloneConfig.d.ts.map +1 -1
  180. package/dist/utils/compileTailwindCss.d.ts +4 -5
  181. package/dist/utils/compileTailwindCss.d.ts.map +1 -1
  182. package/dist/utils/componentSources.d.ts +4 -5
  183. package/dist/utils/componentSources.d.ts.map +1 -1
  184. package/dist/utils/cssBox.d.ts +6 -7
  185. package/dist/utils/cssBox.d.ts.map +1 -1
  186. package/dist/utils/decodeStyleEntities.d.ts +1 -2
  187. package/dist/utils/decodeStyleEntities.d.ts.map +1 -1
  188. package/dist/utils/detect.d.ts +1 -2
  189. package/dist/utils/detect.d.ts.map +1 -1
  190. package/dist/utils/output-markers.d.ts +4 -5
  191. package/dist/utils/output-markers.d.ts.map +1 -1
  192. package/dist/utils/staticPaths.d.ts +5 -0
  193. package/dist/utils/staticPaths.d.ts.map +1 -0
  194. package/dist/utils/staticPaths.js +11 -0
  195. package/dist/utils/staticPaths.js.map +1 -0
  196. package/dist/utils/url.d.ts +4 -5
  197. package/dist/utils/url.d.ts.map +1 -1
  198. package/dist/utils/watchPaths.d.ts +2 -3
  199. package/dist/utils/watchPaths.d.ts.map +1 -1
  200. package/node_modules/tinyexec/dist/main.d.mts +5 -3
  201. package/node_modules/tinyexec/dist/main.mjs +256 -232
  202. package/node_modules/tinyexec/package.json +9 -9
  203. package/package.json +5 -5
  204. package/dist/server/ui/.vite/deps/vue.runtime.esm-bundler-S54atuNJ.js.map +0 -1
@@ -1,165 +1,168 @@
1
- import { spawn as e, spawnSync as t } from "node:child_process";
2
- import { cwd as n } from "node:process";
3
- import { basename as r, delimiter as i, dirname as a, normalize as o, resolve as s } from "node:path";
4
- import { pipeline as c } from "node:stream/promises";
5
- import { PassThrough as l } from "node:stream";
6
- import u from "node:readline";
7
- import { closeSync as d, openSync as f, readSync as p, statSync as m } from "node:fs";
1
+ import { spawn, spawnSync } from "node:child_process";
2
+ import { cwd } from "node:process";
3
+ import { basename, delimiter, dirname, normalize, resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { pipeline } from "node:stream/promises";
6
+ import { PassThrough } from "node:stream";
7
+ import readline from "node:readline";
8
+ import { closeSync, openSync, readSync, statSync } from "node:fs";
8
9
  //#region src/env.ts
9
- const h = /^path$/i;
10
- const g = {
10
+ const isPathLikePattern = /^path$/i;
11
+ const defaultEnvPathInfo = {
11
12
  key: "PATH",
12
13
  value: ""
13
14
  };
14
- function _(e) {
15
- for (const t in e) {
16
- if (!Object.prototype.hasOwnProperty.call(e, t) || !h.test(t)) continue;
17
- const n = e[t];
18
- if (!n) return g;
15
+ function getPathFromEnv(env) {
16
+ for (const key in env) {
17
+ if (!Object.prototype.hasOwnProperty.call(env, key) || !isPathLikePattern.test(key)) continue;
18
+ const value = env[key];
19
+ if (!value) return defaultEnvPathInfo;
19
20
  return {
20
- key: t,
21
- value: n
21
+ key,
22
+ value
22
23
  };
23
24
  }
24
- return g;
25
+ return defaultEnvPathInfo;
25
26
  }
26
- function v(e, t) {
27
- const n = t.value.split(i);
28
- const r = [];
29
- let o = e;
30
- let c;
27
+ function addNodeBinToPath(cwd, path) {
28
+ const parts = path.value.split(delimiter);
29
+ const nodeBinPaths = [];
30
+ let currentPath = typeof cwd === "string" ? cwd : fileURLToPath(cwd, { windows: false });
31
+ let lastPath;
31
32
  do {
32
- r.push(s(o, "node_modules", ".bin"));
33
- c = o;
34
- o = a(o);
35
- } while (o !== c);
36
- r.push(a(process.execPath));
37
- const l = r.concat(n).join(i);
33
+ nodeBinPaths.push(resolve(currentPath, "node_modules", ".bin"));
34
+ lastPath = currentPath;
35
+ currentPath = dirname(currentPath);
36
+ } while (currentPath !== lastPath);
37
+ nodeBinPaths.push(dirname(process.execPath));
38
+ const newPath = nodeBinPaths.concat(parts).join(delimiter);
38
39
  return {
39
- key: t.key,
40
- value: l
40
+ key: path.key,
41
+ value: newPath
41
42
  };
42
43
  }
43
- function y(e, t, n = true) {
44
- const r = {
44
+ function computeEnv(cwd, env, nodePath = true) {
45
+ const envWithDefault = {
45
46
  ...process.env,
46
- ...t
47
+ ...env
47
48
  };
48
- if (!n) return r;
49
- const i = v(e, _(r));
50
- r[i.key] = i.value;
51
- return r;
49
+ if (!nodePath) return envWithDefault;
50
+ const envPathInfo = addNodeBinToPath(cwd, getPathFromEnv(envWithDefault));
51
+ envWithDefault[envPathInfo.key] = envPathInfo.value;
52
+ return envWithDefault;
52
53
  }
53
54
  //#endregion
54
55
  //#region src/stream.ts
55
- const b = (e) => {
56
- let t = e.length;
57
- const n = new l();
58
- const r = () => {
59
- if (--t === 0) n.end();
56
+ const combineStreams = (streams) => {
57
+ let streamCount = streams.length;
58
+ const combined = new PassThrough();
59
+ const maybeEmitEnd = () => {
60
+ if (--streamCount === 0) combined.end();
60
61
  };
61
- for (const t of e) c(t, n, { end: false }).then(r).catch(r);
62
- return n;
62
+ for (const stream of streams) pipeline(stream, combined, { end: false }).then(maybeEmitEnd).catch(maybeEmitEnd);
63
+ return combined;
63
64
  };
64
65
  //#endregion
65
66
  //#region src/normalize.ts
66
- const x = /([()\][%!^"`<>&|;, *?])/g;
67
- const S = /^#!\s*(.+)/;
68
- const C = /\.(?:com|exe)$/i;
69
- const w = /node_modules[\\/]\.bin[\\/][^\\/]+\.cmd$/i;
70
- const T = process.platform === "win32";
71
- const E = [
67
+ const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
68
+ const shebangRegExp = /^#!\s*(.+)/;
69
+ const isWindowsExecutableRegExp = /\.(?:com|exe)$/i;
70
+ const isNodeModulesCmdRegExp = /node_modules[\\/]\.bin[\\/][^\\/]+\.cmd$/i;
71
+ const isWindows = process.platform === "win32";
72
+ const defaultPathExt = [
72
73
  ".EXE",
73
74
  ".CMD",
74
75
  ".BAT",
75
76
  ".COM"
76
77
  ];
78
+ const noPathExt = [""];
77
79
  /**
78
80
  * Normalizes the command and arguments to work cross-platform.
79
81
  * On Windows, this basically handles things like shebangs, calling
80
82
  * `node_modules/.bin` commands, and escaping meta characters.
81
83
  * On other platforms, it just returns the command and arguments as-is.
82
84
  */
83
- function D(e, t = [], n = {}) {
84
- if (n.shell === true || !T) return {
85
- command: e,
86
- args: t,
87
- options: n
85
+ function normalizeSpawnCommand(command, args = [], options = {}) {
86
+ if (options.shell === true || !isWindows) return {
87
+ command,
88
+ args,
89
+ options
88
90
  };
89
- let i = O(e, n);
90
- let a = null;
91
- if (i !== null) {
92
- const e = 150;
93
- const t = Buffer.alloc(e);
94
- let n = null;
91
+ let file = resolveCommand(command, options);
92
+ let shebang = null;
93
+ if (file !== null) {
94
+ const size = 150;
95
+ const buffer = Buffer.alloc(size);
96
+ let fd = null;
95
97
  try {
96
- n = f(i, "r");
97
- p(n, t, 0, e, 0);
98
+ fd = openSync(file, "r");
99
+ readSync(fd, buffer, 0, size, 0);
98
100
  } catch {} finally {
99
- if (n !== null) d(n);
101
+ if (fd !== null) closeSync(fd);
100
102
  }
101
- const o = t.toString().match(S);
102
- if (o !== null) {
103
- const e = o[1].trim();
104
- const t = e.indexOf(" ");
105
- const n = t !== -1 ? e.slice(0, t) : e;
106
- const i = t !== -1 ? e.slice(t + 1) : "";
107
- const s = r(n);
108
- a = s === "env" ? i || null : s;
103
+ const match = buffer.toString().match(shebangRegExp);
104
+ if (match !== null) {
105
+ const line = match[1].trim();
106
+ const separatorIndex = line.indexOf(" ");
107
+ const path = separatorIndex !== -1 ? line.slice(0, separatorIndex) : line;
108
+ const argument = separatorIndex !== -1 ? line.slice(separatorIndex + 1) : "";
109
+ const binary = basename(path);
110
+ shebang = binary === "env" ? argument || null : binary;
109
111
  }
110
112
  }
111
- if (a !== null && i !== null) {
112
- t = [i, ...t];
113
- e = a;
114
- i = O(e, n);
113
+ if (shebang !== null && file !== null) {
114
+ args = [file, ...args];
115
+ command = shebang;
116
+ file = resolveCommand(command, options);
115
117
  }
116
- if (i === null || !C.test(i)) {
117
- const r = i !== null && w.test(i);
118
- e = o(e);
119
- e = e.replace(x, "^$1");
120
- t = t.map((e) => {
121
- e = e.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
122
- e = e.replace(/(?=(\\+?)?)\1$/, "$1$1");
123
- e = `"${e}"`;
124
- e = e.replace(x, "^$1");
125
- if (r) e = e.replace(x, "^$1");
126
- return e;
118
+ if (file === null || !isWindowsExecutableRegExp.test(file)) {
119
+ const needsDoubleEscapeMetaChars = file !== null && isNodeModulesCmdRegExp.test(file);
120
+ command = normalize(command);
121
+ command = command.replace(metaCharsRegExp, "^$1");
122
+ args = args.map((arg) => {
123
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
124
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
125
+ arg = `"${arg}"`;
126
+ arg = arg.replace(metaCharsRegExp, "^$1");
127
+ if (needsDoubleEscapeMetaChars) arg = arg.replace(metaCharsRegExp, "^$1");
128
+ return arg;
127
129
  });
128
- t = [
130
+ args = [
129
131
  "/d",
130
132
  "/s",
131
133
  "/c",
132
- `"${[e, ...t].join(" ")}"`
134
+ `"${[command, ...args].join(" ")}"`
133
135
  ];
134
- e = n.env?.comspec ?? "cmd.exe";
135
- n = {
136
- ...n,
136
+ command = options.env?.comspec ?? "cmd.exe";
137
+ options = {
138
+ ...options,
137
139
  windowsVerbatimArguments: true
138
140
  };
139
141
  }
140
142
  return {
141
- command: e,
142
- args: t,
143
- options: n
143
+ command,
144
+ args,
145
+ options
144
146
  };
145
147
  }
146
148
  /**
147
149
  * Resolves the command to an absolute path if possible.
148
150
  * Handles things like traversing PATH and adding extensions from PATHEXT
149
151
  */
150
- function O(e, t) {
151
- const r = (t.cwd ?? n()).toString();
152
- const a = t.env ?? process.env;
153
- const o = _(a).value;
154
- const c = e.includes("/") || e.includes("\\") ? [""] : [r, ...o.split(i)];
155
- const l = a.PATHEXT ? a.PATHEXT.split(i) : E;
156
- if (e.includes(".") && l[0] !== "") l.unshift("");
157
- for (const t of c) {
158
- const n = s(r, t.startsWith("\"") && t.endsWith("\"") && t.length > 1 ? t.slice(1, -1) : t, e);
159
- for (const e of l) {
160
- const t = n + e;
152
+ function resolveCommand(command, options) {
153
+ const cwd$3 = (options.cwd ?? cwd()).toString();
154
+ const env = options.env ?? process.env;
155
+ const PATH = getPathFromEnv(env).value;
156
+ const pathEnv = command.includes("/") || command.includes("\\") ? [""] : [cwd$3, ...PATH.split(delimiter)];
157
+ let pathExt = env.PATHEXT ? env.PATHEXT.split(delimiter) : defaultPathExt;
158
+ if (command.includes(".") && pathExt[0] !== "") pathExt = ["", ...pathExt];
159
+ for (const extensions of [pathExt, noPathExt]) for (const path of pathEnv) {
160
+ const unquoted = path.startsWith("\"") && path.endsWith("\"") && path.length > 1 ? path.slice(1, -1) : path;
161
+ const dest = resolve(cwd$3, unquoted, command);
162
+ for (const ext of extensions) {
163
+ const destWithExt = dest + ext;
161
164
  try {
162
- if (m(t).isFile()) return t;
165
+ if (statSync(destWithExt).isFile()) return destWithExt;
163
166
  } catch {}
164
167
  }
165
168
  }
@@ -167,49 +170,59 @@ function O(e, t) {
167
170
  }
168
171
  //#endregion
169
172
  //#region src/non-zero-exit-error.ts
170
- var k = class extends Error {
173
+ var NonZeroExitError = class extends Error {
171
174
  result;
172
175
  output;
173
- get exitCode() {
174
- if (this.result.exitCode !== null) return this.result.exitCode;
176
+ exitCode;
177
+ get signalCode() {
178
+ return this.result.signalCode;
175
179
  }
176
- constructor(e, t) {
177
- super(`Process exited with non-zero status (${e.exitCode})`);
178
- this.result = e;
179
- this.output = t;
180
+ constructor(result, output, command, args) {
181
+ let target = "The process";
182
+ if (command) target = `The command \`${args?.length ? `${command} ${args.map((a) => /[ "'`()]/.test(a) ? JSON.stringify(a) : a).join(" ")}` : command}\``;
183
+ const exitCode = result.exitCode ?? 1;
184
+ super(result.signalCode !== null ? `${target} was killed by the signal ${result.signalCode}` : `${target} exited with a non-zero status (${exitCode})`);
185
+ this.result = result;
186
+ this.output = output;
187
+ this.exitCode = exitCode;
188
+ Object.defineProperty(this, "result", {
189
+ enumerable: false,
190
+ writable: false,
191
+ configurable: false
192
+ });
180
193
  }
181
194
  };
182
195
  //#endregion
183
196
  //#region src/main.ts
184
- const A = /\r?\n/;
185
- const j = {
197
+ const LINE_SEPARATOR_REGEX = /\r?\n/;
198
+ const defaultOptions = {
186
199
  timeout: void 0,
187
200
  persist: false
188
201
  };
189
- const M = { timeout: void 0 };
190
- const N = { windowsHide: true };
191
- function P(e) {
192
- const t = new AbortController();
193
- for (const n of e) {
194
- if (n.aborted) {
195
- t.abort();
196
- return n;
202
+ const defaultSyncOptions = { timeout: void 0 };
203
+ const defaultNodeOptions = { windowsHide: true };
204
+ function combineSignals(signals) {
205
+ const controller = new AbortController();
206
+ for (const signal of signals) {
207
+ if (signal.aborted) {
208
+ controller.abort();
209
+ return signal;
197
210
  }
198
- const e = () => {
199
- t.abort(n.reason);
211
+ const onAbort = () => {
212
+ controller.abort(signal.reason);
200
213
  };
201
- n.addEventListener("abort", e, { signal: t.signal });
214
+ signal.addEventListener("abort", onAbort, { signal: controller.signal });
202
215
  }
203
- return t.signal;
216
+ return controller.signal;
204
217
  }
205
- async function F(e) {
206
- let t = "";
218
+ async function readStream(stream) {
219
+ let output = "";
207
220
  try {
208
- for await (const n of e) t += n.toString();
221
+ for await (const chunk of stream) output += chunk.toString();
209
222
  } catch {}
210
- return t;
223
+ return output;
211
224
  }
212
- var I = class {
225
+ var ExecProcess = class {
213
226
  _process;
214
227
  _aborted = false;
215
228
  _options;
@@ -227,19 +240,22 @@ var I = class {
227
240
  get exitCode() {
228
241
  if (this._process && this._process.exitCode !== null) return this._process.exitCode;
229
242
  }
230
- constructor(e, t, n) {
243
+ get signalCode() {
244
+ return this._process?.signalCode ?? null;
245
+ }
246
+ constructor(command, args, options) {
231
247
  this._options = {
232
- ...j,
233
- ...n
248
+ ...defaultOptions,
249
+ ...options
234
250
  };
235
- this._command = e;
236
- this._args = t ?? [];
237
- this._processClosed = new Promise((e) => {
238
- this._resolveClose = e;
251
+ this._command = command;
252
+ this._args = args ?? [];
253
+ this._processClosed = new Promise((resolve) => {
254
+ this._resolveClose = resolve;
239
255
  });
240
256
  }
241
- kill(e) {
242
- return this._process?.kill(e) === true;
257
+ kill(signal) {
258
+ return this._process?.kill(signal) === true;
243
259
  }
244
260
  get aborted() {
245
261
  return this._aborted;
@@ -247,142 +263,150 @@ var I = class {
247
263
  get killed() {
248
264
  return this._process?.killed === true;
249
265
  }
250
- pipe(e, t, n) {
251
- return z(e, t, {
252
- ...n,
266
+ pipe(command, args, options) {
267
+ return exec(command, args, {
268
+ ...options,
253
269
  stdin: this
254
270
  });
255
271
  }
256
272
  async *[Symbol.asyncIterator]() {
257
- const e = this._process;
258
- if (!e) return;
259
- const t = [];
260
- if (this._streamErr) t.push(this._streamErr);
261
- if (this._streamOut) t.push(this._streamOut);
262
- const n = b(t);
263
- const r = u.createInterface({ input: n });
264
- for await (const e of r) yield e.toString();
273
+ const proc = this._process;
274
+ if (!proc) return;
275
+ const streams = [];
276
+ if (this._streamErr) streams.push(this._streamErr);
277
+ if (this._streamOut) streams.push(this._streamOut);
278
+ const streamCombined = combineStreams(streams);
279
+ const rl = readline.createInterface({ input: streamCombined });
280
+ for await (const chunk of rl) yield chunk.toString();
265
281
  await this._processClosed;
266
- e.removeAllListeners();
282
+ proc.removeAllListeners();
267
283
  if (this._thrownError) throw this._thrownError;
268
- if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new k(this);
284
+ if (this._options?.throwOnError && (this.exitCode !== 0 && this.exitCode !== void 0 || this.signalCode !== null)) throw new NonZeroExitError(this, void 0, this._command, this._args);
269
285
  }
270
286
  async _waitForOutput() {
271
- const e = this._process;
272
- if (!e) throw new Error("No process was started");
273
- const [t, n] = await Promise.all([this._streamOut ? F(this._streamOut) : "", this._streamErr ? F(this._streamErr) : ""]);
287
+ const proc = this._process;
288
+ if (!proc) throw new Error("No process was started");
289
+ const [stdout, stderr] = await Promise.all([this._streamOut ? readStream(this._streamOut) : "", this._streamErr ? readStream(this._streamErr) : ""]);
274
290
  await this._processClosed;
275
- const { stdin: r } = this._options;
276
- if (r && typeof r !== "string") await r;
277
- e.removeAllListeners();
291
+ const { stdin } = this._options;
292
+ if (stdin && typeof stdin !== "string") await stdin;
293
+ proc.removeAllListeners();
278
294
  if (this._thrownError) throw this._thrownError;
279
- const i = {
280
- stderr: n,
281
- stdout: t,
295
+ const result = {
296
+ stderr,
297
+ stdout,
282
298
  exitCode: this.exitCode
283
299
  };
284
- if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new k(this, i);
285
- return i;
300
+ if (this._options.throwOnError && (this.exitCode !== 0 && this.exitCode !== void 0 || this.signalCode !== null)) throw new NonZeroExitError(this, result, this._command, this._args);
301
+ return result;
286
302
  }
287
- then(e, t) {
288
- return this._waitForOutput().then(e, t);
303
+ then(onfulfilled, onrejected) {
304
+ return this._waitForOutput().then(onfulfilled, onrejected);
289
305
  }
290
306
  _streamOut;
291
307
  _streamErr;
292
308
  spawn() {
293
- const t = n();
294
- const r = this._options;
295
- const i = {
296
- ...N,
297
- ...r.nodeOptions
309
+ const options = this._options;
310
+ const nodeOptions = {
311
+ ...defaultNodeOptions,
312
+ ...options.nodeOptions
298
313
  };
299
- const a = [];
314
+ const cwd$1 = nodeOptions?.cwd ?? cwd();
315
+ const signals = [];
300
316
  this._resetState();
301
- if (r.timeout !== void 0) a.push(AbortSignal.timeout(r.timeout));
302
- if (r.signal !== void 0) a.push(r.signal);
303
- if (r.persist === true) i.detached = true;
304
- if (a.length > 0) i.signal = P(a);
305
- i.env = y(t, i.env, r.nodePath);
306
- const o = D(this._command, this._args, i);
307
- const s = e(o.command, o.args, o.options);
308
- if (s.stderr) this._streamErr = s.stderr;
309
- if (s.stdout) this._streamOut = s.stdout;
310
- this._process = s;
311
- s.once("error", this._onError);
312
- s.once("close", this._onClose);
313
- if (s.stdin) {
314
- const { stdin: e } = r;
315
- if (typeof e === "string") s.stdin.end(e);
316
- else e?.process?.stdout?.pipe(s.stdin);
317
+ if (options.timeout !== void 0) signals.push(AbortSignal.timeout(options.timeout));
318
+ if (options.signal !== void 0) signals.push(options.signal);
319
+ if (options.persist === true) nodeOptions.detached = true;
320
+ if (signals.length > 0) nodeOptions.signal = combineSignals(signals);
321
+ nodeOptions.env = computeEnv(cwd$1, nodeOptions.env, options.nodePath);
322
+ const crossResult = normalizeSpawnCommand(this._command, this._args, nodeOptions);
323
+ const handle = spawn(crossResult.command, crossResult.args, crossResult.options);
324
+ if (handle.stderr) this._streamErr = handle.stderr;
325
+ if (handle.stdout) this._streamOut = handle.stdout;
326
+ this._process = handle;
327
+ handle.once("error", this._onError);
328
+ handle.once("close", this._onClose);
329
+ if (handle.stdin) {
330
+ const { stdin } = options;
331
+ if (typeof stdin === "string") handle.stdin.end(stdin);
332
+ else stdin?.process?.stdout?.pipe(handle.stdin);
317
333
  }
318
334
  }
319
335
  _resetState() {
320
336
  this._aborted = false;
321
- this._processClosed = new Promise((e) => {
322
- this._resolveClose = e;
337
+ this._processClosed = new Promise((resolve) => {
338
+ this._resolveClose = resolve;
323
339
  });
324
340
  this._thrownError = void 0;
325
341
  }
326
- _onError = (e) => {
327
- if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
342
+ _onError = (err) => {
343
+ if (err.name === "AbortError" && (!(err.cause instanceof Error) || err.cause.name !== "TimeoutError")) {
328
344
  this._aborted = true;
329
345
  return;
330
346
  }
331
- this._thrownError = e;
347
+ this._thrownError = err;
332
348
  };
333
349
  _onClose = () => {
334
350
  if (this._resolveClose) this._resolveClose();
335
351
  };
336
352
  };
337
- function L(e, r, i) {
338
- const a = {
339
- ...M,
340
- ...i
353
+ function xSync(command, args, options) {
354
+ const opts = {
355
+ ...defaultSyncOptions,
356
+ ...options
341
357
  };
342
- const o = n();
343
- const s = {
344
- windowsHide: true,
345
- ...a.nodeOptions
358
+ const nodeOptions = {
359
+ ...defaultNodeOptions,
360
+ ...opts.nodeOptions
346
361
  };
347
- if (a.timeout !== void 0) s.timeout = a.timeout;
348
- s.env = y(o, s.env, a.nodePath);
349
- const c = D(e, r ?? [], s);
350
- const l = t(c.command, c.args, c.options);
351
- if (l.error) throw l.error;
352
- const u = l.stdout?.toString() ?? "";
353
- const d = l.stderr?.toString() ?? "";
354
- const f = l.status ?? void 0;
355
- const p = l.signal != null;
356
- const m = {
357
- stdout: u,
358
- stderr: d,
362
+ const cwd$2 = nodeOptions?.cwd ?? cwd();
363
+ if (opts.timeout !== void 0) nodeOptions.timeout = opts.timeout;
364
+ nodeOptions.env = computeEnv(cwd$2, nodeOptions.env, opts.nodePath);
365
+ const crossResult = normalizeSpawnCommand(command, args ?? [], nodeOptions);
366
+ const spawnResult = spawnSync(crossResult.command, crossResult.args, crossResult.options);
367
+ if (spawnResult.error) throw spawnResult.error;
368
+ const stdout = spawnResult.stdout?.toString() ?? "";
369
+ const stderr = spawnResult.stderr?.toString() ?? "";
370
+ const exitCode = spawnResult.status ?? void 0;
371
+ const signalCode = spawnResult.signal ?? null;
372
+ const killed = signalCode !== null;
373
+ const result = {
374
+ stdout,
375
+ stderr,
359
376
  get exitCode() {
360
- return f;
377
+ return exitCode;
378
+ },
379
+ get signalCode() {
380
+ return signalCode;
361
381
  },
362
382
  get pid() {
363
- return l.pid;
383
+ return spawnResult.pid;
364
384
  },
365
385
  get killed() {
366
- return p;
386
+ return killed;
367
387
  },
368
388
  *[Symbol.iterator]() {
369
- for (const e of [u, d]) {
370
- if (!e) continue;
371
- const t = e.split(A);
372
- if (t[t.length - 1] === "") t.pop();
373
- yield* t;
389
+ for (const text of [stdout, stderr]) {
390
+ if (!text) continue;
391
+ const lines = text.split(LINE_SEPARATOR_REGEX);
392
+ if (lines[lines.length - 1] === "") lines.pop();
393
+ yield* lines;
374
394
  }
375
395
  }
376
396
  };
377
- if (a.throwOnError && f !== 0 && f !== void 0) throw new k(m, m);
378
- return m;
397
+ if (opts.throwOnError && (exitCode !== 0 && exitCode !== void 0 || signalCode !== null)) throw new NonZeroExitError(result, {
398
+ stdout: result.stdout,
399
+ stderr: result.stderr,
400
+ exitCode: result.exitCode
401
+ }, command, args);
402
+ return result;
379
403
  }
380
- const R = (e, t, n) => {
381
- const r = new I(e, t, n);
382
- r.spawn();
383
- return r;
404
+ const x = (command, args, userOptions) => {
405
+ const proc = new ExecProcess(command, args, userOptions);
406
+ proc.spawn();
407
+ return proc;
384
408
  };
385
- const z = R;
386
- const B = L;
409
+ const exec = x;
410
+ const execSync = xSync;
387
411
  //#endregion
388
- export { I as ExecProcess, k as NonZeroExitError, z as exec, B as execSync, D as normalizeSpawnCommand, R as x, L as xSync };
412
+ export { ExecProcess, NonZeroExitError, exec, execSync, normalizeSpawnCommand, x, xSync };