@seanhogg/builderforce-webcontainers-core 2026.10.7 → 2026.10.9

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 (385) hide show
  1. package/dist/archive.d.ts +2 -0
  2. package/dist/archive.d.ts.map +1 -1
  3. package/dist/archive.js +6 -4
  4. package/dist/archive.js.map +1 -1
  5. package/dist/build.d.ts +6 -0
  6. package/dist/build.d.ts.map +1 -1
  7. package/dist/build.js +9 -1
  8. package/dist/build.js.map +1 -1
  9. package/dist/buildHost.d.ts +3 -0
  10. package/dist/buildHost.d.ts.map +1 -1
  11. package/dist/buildHost.js +25 -12
  12. package/dist/buildHost.js.map +1 -1
  13. package/dist/compileComponent.d.ts.map +1 -1
  14. package/dist/compileComponent.js +4 -1
  15. package/dist/compileComponent.js.map +1 -1
  16. package/dist/compileScript.d.ts +12 -4
  17. package/dist/compileScript.d.ts.map +1 -1
  18. package/dist/compileScript.js +26 -13
  19. package/dist/compileScript.js.map +1 -1
  20. package/dist/components.d.ts +5 -0
  21. package/dist/components.d.ts.map +1 -1
  22. package/dist/components.js.map +1 -1
  23. package/dist/detectProject.d.ts +2 -0
  24. package/dist/detectProject.d.ts.map +1 -1
  25. package/dist/detectProject.js +13 -7
  26. package/dist/detectProject.js.map +1 -1
  27. package/dist/devServer.d.ts +38 -4
  28. package/dist/devServer.d.ts.map +1 -1
  29. package/dist/devServer.js +140 -24
  30. package/dist/devServer.js.map +1 -1
  31. package/dist/devStyles.d.ts +27 -0
  32. package/dist/devStyles.d.ts.map +1 -0
  33. package/dist/devStyles.js +52 -0
  34. package/dist/devStyles.js.map +1 -0
  35. package/dist/hot/client.d.ts +33 -0
  36. package/dist/hot/client.d.ts.map +1 -0
  37. package/dist/hot/client.js +46 -0
  38. package/dist/hot/client.js.map +1 -0
  39. package/dist/hot/moduleGraph.d.ts +39 -0
  40. package/dist/hot/moduleGraph.d.ts.map +1 -0
  41. package/dist/hot/moduleGraph.js +69 -0
  42. package/dist/hot/moduleGraph.js.map +1 -0
  43. package/dist/hot/planUpdate.d.ts +33 -0
  44. package/dist/hot/planUpdate.d.ts.map +1 -0
  45. package/dist/hot/planUpdate.js +43 -0
  46. package/dist/hot/planUpdate.js.map +1 -0
  47. package/dist/hot/reactRefresh.d.ts +45 -0
  48. package/dist/hot/reactRefresh.d.ts.map +1 -0
  49. package/dist/hot/reactRefresh.js +86 -0
  50. package/dist/hot/reactRefresh.js.map +1 -0
  51. package/dist/html.d.ts +4 -8
  52. package/dist/html.d.ts.map +1 -1
  53. package/dist/html.js +15 -19
  54. package/dist/html.js.map +1 -1
  55. package/dist/index.d.ts +20 -1
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +12 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/installer/tree.d.ts.map +1 -1
  60. package/dist/installer/tree.js +22 -4
  61. package/dist/installer/tree.js.map +1 -1
  62. package/dist/installer/wasmBuilds.d.ts +27 -0
  63. package/dist/installer/wasmBuilds.d.ts.map +1 -0
  64. package/dist/installer/wasmBuilds.js +32 -0
  65. package/dist/installer/wasmBuilds.js.map +1 -0
  66. package/dist/node/builtins.d.ts +6 -1
  67. package/dist/node/builtins.d.ts.map +1 -1
  68. package/dist/node/builtins.js +15 -10
  69. package/dist/node/builtins.js.map +1 -1
  70. package/dist/node/childProcess.d.ts +3 -3
  71. package/dist/node/childProcess.d.ts.map +1 -1
  72. package/dist/node/childProcess.js +68 -16
  73. package/dist/node/childProcess.js.map +1 -1
  74. package/dist/node/crypto.d.ts.map +1 -1
  75. package/dist/node/crypto.js +5 -4
  76. package/dist/node/crypto.js.map +1 -1
  77. package/dist/node/esm.d.ts +7 -0
  78. package/dist/node/esm.d.ts.map +1 -1
  79. package/dist/node/esm.js +28 -2
  80. package/dist/node/esm.js.map +1 -1
  81. package/dist/node/fs/index.d.ts +3 -0
  82. package/dist/node/fs/index.d.ts.map +1 -1
  83. package/dist/node/fs/index.js +22 -106
  84. package/dist/node/fs/index.js.map +1 -1
  85. package/dist/node/fs/stdinFd.d.ts +10 -0
  86. package/dist/node/fs/stdinFd.d.ts.map +1 -0
  87. package/dist/node/fs/stdinFd.js +40 -0
  88. package/dist/node/fs/stdinFd.js.map +1 -0
  89. package/dist/node/fs/streams.d.ts +24 -0
  90. package/dist/node/fs/streams.d.ts.map +1 -0
  91. package/dist/node/fs/streams.js +144 -0
  92. package/dist/node/fs/streams.js.map +1 -0
  93. package/dist/node/fs/sync.d.ts +2 -0
  94. package/dist/node/fs/sync.d.ts.map +1 -1
  95. package/dist/node/fs/sync.js +17 -0
  96. package/dist/node/fs/sync.js.map +1 -1
  97. package/dist/node/globalObject.d.ts +25 -0
  98. package/dist/node/globalObject.d.ts.map +1 -0
  99. package/dist/node/globalObject.js +83 -0
  100. package/dist/node/globalObject.js.map +1 -0
  101. package/dist/node/http/client.d.ts +3 -1
  102. package/dist/node/http/client.d.ts.map +1 -1
  103. package/dist/node/http/client.js +74 -5
  104. package/dist/node/http/client.js.map +1 -1
  105. package/dist/node/http/index.d.ts.map +1 -1
  106. package/dist/node/http/index.js +6 -4
  107. package/dist/node/http/index.js.map +1 -1
  108. package/dist/node/http/messages.d.ts +87 -0
  109. package/dist/node/http/messages.d.ts.map +1 -0
  110. package/dist/node/http/messages.js +146 -0
  111. package/dist/node/http/messages.js.map +1 -0
  112. package/dist/node/http/server.d.ts +13 -98
  113. package/dist/node/http/server.d.ts.map +1 -1
  114. package/dist/node/http/server.js +41 -206
  115. package/dist/node/http/server.js.map +1 -1
  116. package/dist/node/http/serverResponse.d.ts +45 -0
  117. package/dist/node/http/serverResponse.d.ts.map +1 -0
  118. package/dist/node/http/serverResponse.js +96 -0
  119. package/dist/node/http/serverResponse.js.map +1 -0
  120. package/dist/node/http/upgradeSocket.d.ts +34 -0
  121. package/dist/node/http/upgradeSocket.d.ts.map +1 -0
  122. package/dist/node/http/upgradeSocket.js +73 -0
  123. package/dist/node/http/upgradeSocket.js.map +1 -0
  124. package/dist/node/ipc.d.ts +26 -0
  125. package/dist/node/ipc.d.ts.map +1 -0
  126. package/dist/node/ipc.js +76 -0
  127. package/dist/node/ipc.js.map +1 -0
  128. package/dist/node/loader.d.ts +2 -0
  129. package/dist/node/loader.d.ts.map +1 -1
  130. package/dist/node/loader.js +79 -14
  131. package/dist/node/loader.js.map +1 -1
  132. package/dist/node/misc.d.ts.map +1 -1
  133. package/dist/node/misc.js +20 -5
  134. package/dist/node/misc.js.map +1 -1
  135. package/dist/node/process.d.ts +2 -5
  136. package/dist/node/process.d.ts.map +1 -1
  137. package/dist/node/process.js +16 -11
  138. package/dist/node/process.js.map +1 -1
  139. package/dist/node/processExit.d.ts +13 -0
  140. package/dist/node/processExit.d.ts.map +1 -0
  141. package/dist/node/processExit.js +25 -0
  142. package/dist/node/processExit.js.map +1 -0
  143. package/dist/node/program.d.ts.map +1 -1
  144. package/dist/node/program.js +6 -5
  145. package/dist/node/program.js.map +1 -1
  146. package/dist/node/runtime.d.ts +6 -1
  147. package/dist/node/runtime.d.ts.map +1 -1
  148. package/dist/node/runtime.js +25 -17
  149. package/dist/node/runtime.js.map +1 -1
  150. package/dist/node/stream/readable.d.ts +2 -1
  151. package/dist/node/stream/readable.d.ts.map +1 -1
  152. package/dist/node/stream/readable.js +2 -1
  153. package/dist/node/stream/readable.js.map +1 -1
  154. package/dist/node/urlqs.d.ts +1 -1
  155. package/dist/node/urlqs.d.ts.map +1 -1
  156. package/dist/node/urlqs.js +11 -2
  157. package/dist/node/urlqs.js.map +1 -1
  158. package/dist/node/workerThreads.d.ts +31 -0
  159. package/dist/node/workerThreads.d.ts.map +1 -0
  160. package/dist/node/workerThreads.js +165 -0
  161. package/dist/node/workerThreads.js.map +1 -0
  162. package/dist/node/zlib.d.ts.map +1 -1
  163. package/dist/node/zlib.js +23 -2
  164. package/dist/node/zlib.js.map +1 -1
  165. package/dist/previewBridge.d.ts +42 -0
  166. package/dist/previewBridge.d.ts.map +1 -0
  167. package/dist/previewBridge.js +192 -0
  168. package/dist/previewBridge.js.map +1 -0
  169. package/dist/shell/ast.d.ts +101 -0
  170. package/dist/shell/ast.d.ts.map +1 -0
  171. package/dist/shell/ast.js +7 -0
  172. package/dist/shell/ast.js.map +1 -0
  173. package/dist/shell/builtins.d.ts +14 -0
  174. package/dist/shell/builtins.d.ts.map +1 -1
  175. package/dist/shell/builtins.js +87 -7
  176. package/dist/shell/builtins.js.map +1 -1
  177. package/dist/shell/compound.d.ts +30 -0
  178. package/dist/shell/compound.d.ts.map +1 -0
  179. package/dist/shell/compound.js +73 -0
  180. package/dist/shell/compound.js.map +1 -0
  181. package/dist/shell/context.d.ts.map +1 -1
  182. package/dist/shell/context.js +2 -2
  183. package/dist/shell/context.js.map +1 -1
  184. package/dist/shell/devHandoff.d.ts +10 -4
  185. package/dist/shell/devHandoff.d.ts.map +1 -1
  186. package/dist/shell/devHandoff.js +7 -5
  187. package/dist/shell/devHandoff.js.map +1 -1
  188. package/dist/shell/exec.d.ts +27 -6
  189. package/dist/shell/exec.d.ts.map +1 -1
  190. package/dist/shell/exec.js +133 -46
  191. package/dist/shell/exec.js.map +1 -1
  192. package/dist/shell/expand.d.ts +5 -1
  193. package/dist/shell/expand.d.ts.map +1 -1
  194. package/dist/shell/expand.js +7 -5
  195. package/dist/shell/expand.js.map +1 -1
  196. package/dist/shell/lineReader.d.ts +9 -0
  197. package/dist/shell/lineReader.d.ts.map +1 -0
  198. package/dist/shell/lineReader.js +42 -0
  199. package/dist/shell/lineReader.js.map +1 -0
  200. package/dist/shell/npm.js +2 -2
  201. package/dist/shell/npm.js.map +1 -1
  202. package/dist/shell/packageManagers.d.ts +20 -0
  203. package/dist/shell/packageManagers.d.ts.map +1 -0
  204. package/dist/shell/packageManagers.js +74 -0
  205. package/dist/shell/packageManagers.js.map +1 -0
  206. package/dist/shell/parse.d.ts +16 -66
  207. package/dist/shell/parse.d.ts.map +1 -1
  208. package/dist/shell/parse.js +244 -243
  209. package/dist/shell/parse.js.map +1 -1
  210. package/dist/shell/program.d.ts.map +1 -1
  211. package/dist/shell/program.js +7 -6
  212. package/dist/shell/program.js.map +1 -1
  213. package/dist/shell/testCommand.d.ts +9 -0
  214. package/dist/shell/testCommand.d.ts.map +1 -0
  215. package/dist/shell/testCommand.js +105 -0
  216. package/dist/shell/testCommand.js.map +1 -0
  217. package/dist/shell/tokenize.d.ts +25 -0
  218. package/dist/shell/tokenize.d.ts.map +1 -0
  219. package/dist/shell/tokenize.js +279 -0
  220. package/dist/shell/tokenize.js.map +1 -0
  221. package/dist/styleModules.d.ts +2 -5
  222. package/dist/styleModules.d.ts.map +1 -1
  223. package/dist/styleModules.js +23 -14
  224. package/dist/styleModules.js.map +1 -1
  225. package/dist/styles/compile.d.ts +18 -0
  226. package/dist/styles/compile.d.ts.map +1 -0
  227. package/dist/styles/compile.js +34 -0
  228. package/dist/styles/compile.js.map +1 -0
  229. package/dist/styles/compilers.d.ts +75 -0
  230. package/dist/styles/compilers.d.ts.map +1 -0
  231. package/dist/styles/compilers.js +77 -0
  232. package/dist/styles/compilers.js.map +1 -0
  233. package/dist/styles/cssModules.d.ts +40 -0
  234. package/dist/styles/cssModules.d.ts.map +1 -0
  235. package/dist/styles/cssModules.js +239 -0
  236. package/dist/styles/cssModules.js.map +1 -0
  237. package/dist/styles/imports.d.ts +37 -0
  238. package/dist/styles/imports.d.ts.map +1 -0
  239. package/dist/styles/imports.js +88 -0
  240. package/dist/styles/imports.js.map +1 -0
  241. package/dist/styles/languages.d.ts +13 -0
  242. package/dist/styles/languages.d.ts.map +1 -0
  243. package/dist/styles/languages.js +20 -0
  244. package/dist/styles/languages.js.map +1 -0
  245. package/dist/styles/packageStyles.d.ts +19 -0
  246. package/dist/styles/packageStyles.d.ts.map +1 -0
  247. package/dist/styles/packageStyles.js +32 -0
  248. package/dist/styles/packageStyles.js.map +1 -0
  249. package/dist/svelteCompiler.d.ts.map +1 -1
  250. package/dist/svelteCompiler.js +19 -2
  251. package/dist/svelteCompiler.js.map +1 -1
  252. package/dist/system/commands.d.ts +2 -0
  253. package/dist/system/commands.d.ts.map +1 -1
  254. package/dist/system/commands.js +18 -0
  255. package/dist/system/commands.js.map +1 -1
  256. package/dist/system/cookieJar.d.ts +59 -0
  257. package/dist/system/cookieJar.d.ts.map +1 -0
  258. package/dist/system/cookieJar.js +187 -0
  259. package/dist/system/cookieJar.js.map +1 -0
  260. package/dist/system/httpStream.d.ts +40 -0
  261. package/dist/system/httpStream.d.ts.map +1 -0
  262. package/dist/system/httpStream.js +156 -0
  263. package/dist/system/httpStream.js.map +1 -0
  264. package/dist/system/index.d.ts +11 -1
  265. package/dist/system/index.d.ts.map +1 -1
  266. package/dist/system/index.js +5 -0
  267. package/dist/system/index.js.map +1 -1
  268. package/dist/system/ipc.d.ts +33 -0
  269. package/dist/system/ipc.d.ts.map +1 -0
  270. package/dist/system/ipc.js +65 -0
  271. package/dist/system/ipc.js.map +1 -0
  272. package/dist/system/kernel.d.ts +10 -2
  273. package/dist/system/kernel.d.ts.map +1 -1
  274. package/dist/system/kernel.js +18 -6
  275. package/dist/system/kernel.js.map +1 -1
  276. package/dist/system/ports.d.ts +9 -4
  277. package/dist/system/ports.d.ts.map +1 -1
  278. package/dist/system/ports.js +21 -2
  279. package/dist/system/ports.js.map +1 -1
  280. package/dist/system/process.d.ts +3 -0
  281. package/dist/system/process.d.ts.map +1 -1
  282. package/dist/system/process.js +50 -26
  283. package/dist/system/process.js.map +1 -1
  284. package/dist/system/programs.d.ts +1 -1
  285. package/dist/system/programs.d.ts.map +1 -1
  286. package/dist/system/programs.js +2 -0
  287. package/dist/system/programs.js.map +1 -1
  288. package/dist/system/terminal.d.ts +10 -4
  289. package/dist/system/terminal.d.ts.map +1 -1
  290. package/dist/system/terminal.js +21 -13
  291. package/dist/system/terminal.js.map +1 -1
  292. package/dist/system/types.d.ts +65 -13
  293. package/dist/system/types.d.ts.map +1 -1
  294. package/dist/system/webSocketClient.d.ts +37 -0
  295. package/dist/system/webSocketClient.d.ts.map +1 -0
  296. package/dist/system/webSocketClient.js +152 -0
  297. package/dist/system/webSocketClient.js.map +1 -0
  298. package/dist/system/webSocketFrames.d.ts +39 -0
  299. package/dist/system/webSocketFrames.d.ts.map +1 -0
  300. package/dist/system/webSocketFrames.js +117 -0
  301. package/dist/system/webSocketFrames.js.map +1 -0
  302. package/dist/vueCompiler.d.ts.map +1 -1
  303. package/dist/vueCompiler.js +11 -8
  304. package/dist/vueCompiler.js.map +1 -1
  305. package/package.json +4 -1
  306. package/src/archive.ts +8 -4
  307. package/src/build.ts +13 -1
  308. package/src/buildHost.ts +23 -10
  309. package/src/compileComponent.ts +4 -1
  310. package/src/compileScript.ts +30 -11
  311. package/src/components.ts +5 -0
  312. package/src/detectProject.ts +13 -6
  313. package/src/devServer.ts +148 -23
  314. package/src/devStyles.ts +70 -0
  315. package/src/hot/client.ts +70 -0
  316. package/src/hot/moduleGraph.ts +90 -0
  317. package/src/hot/planUpdate.ts +66 -0
  318. package/src/hot/reactRefresh.ts +93 -0
  319. package/src/html.ts +17 -21
  320. package/src/index.ts +20 -1
  321. package/src/installer/tree.ts +22 -4
  322. package/src/installer/wasmBuilds.ts +45 -0
  323. package/src/node/builtins.ts +21 -12
  324. package/src/node/childProcess.ts +73 -20
  325. package/src/node/crypto.ts +5 -4
  326. package/src/node/esm.ts +26 -2
  327. package/src/node/fs/index.ts +26 -103
  328. package/src/node/fs/stdinFd.ts +44 -0
  329. package/src/node/fs/streams.ts +177 -0
  330. package/src/node/fs/sync.ts +15 -0
  331. package/src/node/globalObject.ts +82 -0
  332. package/src/node/http/client.ts +69 -6
  333. package/src/node/http/index.ts +6 -4
  334. package/src/node/http/messages.ts +150 -0
  335. package/src/node/http/server.ts +44 -206
  336. package/src/node/http/serverResponse.ts +105 -0
  337. package/src/node/http/upgradeSocket.ts +79 -0
  338. package/src/node/ipc.ts +91 -0
  339. package/src/node/loader.ts +78 -14
  340. package/src/node/misc.ts +19 -5
  341. package/src/node/process.ts +15 -8
  342. package/src/node/processExit.ts +21 -0
  343. package/src/node/program.ts +12 -9
  344. package/src/node/runtime.ts +29 -17
  345. package/src/node/stream/readable.ts +2 -1
  346. package/src/node/urlqs.ts +10 -2
  347. package/src/node/workerThreads.ts +198 -0
  348. package/src/node/zlib.ts +24 -2
  349. package/src/previewBridge.ts +194 -0
  350. package/src/shell/ast.ts +85 -0
  351. package/src/shell/builtins.ts +97 -7
  352. package/src/shell/compound.ts +89 -0
  353. package/src/shell/context.ts +2 -2
  354. package/src/shell/devHandoff.ts +16 -9
  355. package/src/shell/exec.ts +134 -45
  356. package/src/shell/expand.ts +8 -6
  357. package/src/shell/lineReader.ts +46 -0
  358. package/src/shell/npm.ts +2 -2
  359. package/src/shell/packageManagers.ts +75 -0
  360. package/src/shell/parse.ts +233 -236
  361. package/src/shell/program.ts +7 -6
  362. package/src/shell/testCommand.ts +105 -0
  363. package/src/shell/tokenize.ts +257 -0
  364. package/src/styleModules.ts +30 -14
  365. package/src/styles/compile.ts +43 -0
  366. package/src/styles/compilers.ts +143 -0
  367. package/src/styles/cssModules.ts +254 -0
  368. package/src/styles/imports.ts +125 -0
  369. package/src/styles/languages.ts +29 -0
  370. package/src/styles/packageStyles.ts +35 -0
  371. package/src/svelteCompiler.ts +20 -3
  372. package/src/system/commands.ts +17 -0
  373. package/src/system/cookieJar.ts +187 -0
  374. package/src/system/httpStream.ts +168 -0
  375. package/src/system/index.ts +28 -1
  376. package/src/system/ipc.ts +89 -0
  377. package/src/system/kernel.ts +22 -7
  378. package/src/system/ports.ts +23 -4
  379. package/src/system/process.ts +57 -30
  380. package/src/system/programs.ts +3 -1
  381. package/src/system/terminal.ts +34 -12
  382. package/src/system/types.ts +71 -13
  383. package/src/system/webSocketClient.ts +177 -0
  384. package/src/system/webSocketFrames.ts +118 -0
  385. package/src/vueCompiler.ts +11 -8
@@ -0,0 +1,74 @@
1
+ /**
2
+ * `pnpm` and `yarn`, as front ends to the same installer and script runner
3
+ * `npm` uses: their commands are translated to npm's, so `pnpm add -D x`,
4
+ * `yarn dev` or `pnpm dlx create-vite` behave as a project's README expects.
5
+ * The tree is npm-style (hoisted `node_modules`, `package-lock.json`);
6
+ * `pnpm-lock.yaml` and `yarn.lock` are not read.
7
+ */
8
+ import { join } from '../paths.js';
9
+ import { findPackageScope } from '../node/resolve.js';
10
+ import { findExecutable } from '../system/commands.js';
11
+ import { npmCommand, npxCommand } from './npm.js';
12
+ const VERSIONS = { pnpm: '9.12.0', yarn: '1.22.22' };
13
+ const INSTALL = new Set(['install', 'i']);
14
+ const REMOVE = new Set(['remove', 'rm', 'uninstall', 'un']);
15
+ const NPM_PASSTHROUGH = new Set(['test', 't', 'start', 'init', 'ls', 'list', 'run', 'run-script']);
16
+ function hasScript(ctx, name) {
17
+ const dir = findPackageScope(ctx.fs, ctx.cwd)?.dir ?? ctx.cwd;
18
+ try {
19
+ const pkg = JSON.parse(ctx.fs.readText(join(dir, 'package.json')) ?? '{}');
20
+ return !!pkg.scripts?.[name];
21
+ }
22
+ catch {
23
+ return false;
24
+ }
25
+ }
26
+ /** Map `--dev` / `-D` to npm's flag; drop flags npm has no use for here. */
27
+ function addFlags(args) {
28
+ return args.flatMap((a) => (a === '--dev' || a === '-D' || a === '--save-dev' ? ['--save-dev'] : a === '--frozen-lockfile' || a === '--immutable' || a === '--prefer-offline' ? [] : [a]));
29
+ }
30
+ /** The npm (or npx) command line a pnpm/yarn command stands for, or a message when there is none. */
31
+ export function translate(manager, args, ctx) {
32
+ const [sub, ...rest] = args;
33
+ if (sub === undefined)
34
+ return { tool: 'npm', args: ['install'] };
35
+ if (sub === '-v' || sub === '--version')
36
+ return { version: VERSIONS[manager] };
37
+ if (INSTALL.has(sub)) {
38
+ // `yarn install x` is an error in yarn; treat any operands as `add` for both.
39
+ const flags = addFlags(rest);
40
+ return { tool: 'npm', args: ['install', ...flags] };
41
+ }
42
+ if (sub === 'add')
43
+ return { tool: 'npm', args: ['install', ...addFlags(rest)] };
44
+ if (REMOVE.has(sub))
45
+ return { tool: 'npm', args: ['uninstall', ...rest] };
46
+ if (sub === 'dlx' || sub === 'exec' || (manager === 'pnpm' && sub === 'x'))
47
+ return { tool: 'npx', args: rest };
48
+ if (NPM_PASSTHROUGH.has(sub))
49
+ return { tool: 'npm', args: [sub, ...rest] };
50
+ // `pnpm dev` / `yarn build`: a script of that name, else an installed bin.
51
+ if (hasScript(ctx, sub))
52
+ return { tool: 'npm', args: ['run', sub, ...(rest.length ? ['--', ...rest] : [])] };
53
+ if (findExecutable(ctx.fs, sub, ctx.cwd, { PATH: '' }))
54
+ return { tool: 'npx', args: [sub, ...rest] };
55
+ return { error: `${manager}: no script or command named "${sub}"` };
56
+ }
57
+ function frontEnd(manager) {
58
+ return async (ctx, shell, input) => {
59
+ const plan = translate(manager, ctx.args, ctx);
60
+ if ('version' in plan) {
61
+ ctx.io.stdout(`${plan.version}\n`);
62
+ return 0;
63
+ }
64
+ if ('error' in plan) {
65
+ ctx.io.stderr(`${plan.error}\n`);
66
+ return 1;
67
+ }
68
+ const next = { ...ctx, args: plan.args, name: plan.tool };
69
+ return plan.tool === 'npm' ? npmCommand(next, shell, input) : npxCommand(next, shell, input);
70
+ };
71
+ }
72
+ export const pnpmCommand = frontEnd('pnpm');
73
+ export const yarnCommand = frontEnd('yarn');
74
+ //# sourceMappingURL=packageManagers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageManagers.js","sourceRoot":"","sources":["../../src/shell/packageManagers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,QAAQ,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAW,CAAC;AAI9D,MAAM,OAAO,GAAG,I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AAC,IAAI,EAAE,CAAC;QAC1D,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC/F,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC"}
@@ -1,73 +1,23 @@
1
1
  /**
2
2
  * The shell grammar, a practical subset of POSIX sh:
3
3
  *
4
- * script := list (('\n' | ';' | '&') list)*
5
- * list := pipeline (('&&' | '||') pipeline)*
6
- * pipeline := ['!'] command ('|' command)*
7
- * command := (NAME=word)* word* redirect*
8
- * redirect := ('>' | '>>' | '<' | '2>' | '2>>' | '&>') word | '2>&1' | '>&2'
4
+ * script := list (('\n' | ';' | '&') list)*
5
+ * list := pipeline (('&&' | '||') pipeline)*
6
+ * pipeline := ['!'] command ('|' command)*
7
+ * command := simple | compound redirect* | function
8
+ * simple := (NAME=word)* word* redirect*
9
+ * compound := if … then … [elif … then …]* [else …] fi
10
+ * | while|until … do … done | for NAME [in word*] do … done
11
+ * | case word in (pattern [| pattern]*) … ;; … esac
12
+ * | '{' script '}' | '(' script ')'
13
+ * function := NAME '(' ')' compound | 'function' NAME ['(' ')'] compound
14
+ * redirect := ('>' | '>>' | '<' | '2>' | '2>>' | '&>') word | '2>&1' | '>&2' | ('<<' | '<<-') DELIM
9
15
  *
10
- * Words keep their quoting as segments, because expansion (variables, `$(…)`,
11
- * `~`, globs, field splitting) happens at run time and depends on it.
16
+ * Reserved words count only in command position and unquoted, as in sh, so
17
+ * `echo done` prints "done".
12
18
  */
13
- export type Segment = {
14
- kind: 'text';
15
- value: string;
16
- quoted: boolean;
17
- } | {
18
- kind: 'var';
19
- name: string;
20
- quoted: boolean;
21
- op?: ':-' | '-' | ':=' | ':+';
22
- arg?: Word;
23
- } | {
24
- kind: 'cmd';
25
- source: string;
26
- quoted: boolean;
27
- } | {
28
- kind: 'tilde';
29
- };
30
- export type Word = Segment[];
31
- export type RedirectOp = '>' | '>>' | '<' | '2>' | '2>>' | '&>' | '2>&1' | '>&2';
32
- export interface Redirect {
33
- op: RedirectOp;
34
- target?: Word;
35
- }
36
- export interface Command {
37
- assignments: Array<{
38
- name: string;
39
- value: Word;
40
- }>;
41
- words: Word[];
42
- redirects: Redirect[];
43
- }
44
- export interface Pipeline {
45
- negate: boolean;
46
- commands: Command[];
47
- }
48
- export interface AndOrList {
49
- first: Pipeline;
50
- rest: Array<{
51
- op: '&&' | '||';
52
- pipeline: Pipeline;
53
- }>;
54
- background: boolean;
55
- }
56
- export type Script = AndOrList[];
57
- type Token = {
58
- type: 'word';
59
- word: Word;
60
- raw: string;
61
- } | {
62
- type: 'op';
63
- op: string;
64
- };
65
- export declare class ShellSyntaxError extends Error {
66
- readonly incomplete: boolean;
67
- /** The input ended inside a quote or after `|`/`&&`: an interactive shell asks for more. */
68
- constructor(message: string, incomplete?: boolean);
69
- }
70
- export declare function tokenize(input: string, wordOnly?: boolean): Token[];
19
+ import type { Script } from './ast.js';
20
+ export type * from './ast.js';
21
+ export { ShellSyntaxError, tokenize } from './tokenize.js';
71
22
  export declare function parse(input: string): Script;
72
- export {};
73
23
  //# sourceMappingURL=parse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/shell/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,OAAO,GACf;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAChD;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,E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