mikrojs 0.0.0 → 0.0.8

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 (497) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +76 -0
  3. package/bin/mikrojs.js +3 -0
  4. package/dist/_exports/ble.d.ts +3 -0
  5. package/dist/_exports/ble.d.ts.map +1 -0
  6. package/dist/_exports/ble.js +2 -0
  7. package/dist/_exports/ble.js.map +1 -0
  8. package/dist/_exports/cbor.d.ts +3 -0
  9. package/dist/_exports/cbor.d.ts.map +1 -0
  10. package/dist/_exports/cbor.js +2 -0
  11. package/dist/_exports/cbor.js.map +1 -0
  12. package/dist/_exports/console.d.ts +2 -0
  13. package/dist/_exports/console.d.ts.map +1 -0
  14. package/dist/_exports/console.js +2 -0
  15. package/dist/_exports/console.js.map +1 -0
  16. package/dist/_exports/env.d.ts +2 -0
  17. package/dist/_exports/env.d.ts.map +1 -0
  18. package/dist/_exports/env.js +2 -0
  19. package/dist/_exports/env.js.map +1 -0
  20. package/dist/_exports/format.d.ts +2 -0
  21. package/dist/_exports/format.d.ts.map +1 -0
  22. package/dist/_exports/format.js +2 -0
  23. package/dist/_exports/format.js.map +1 -0
  24. package/dist/_exports/fs.d.ts +2 -0
  25. package/dist/_exports/fs.d.ts.map +1 -0
  26. package/dist/_exports/fs.js +2 -0
  27. package/dist/_exports/fs.js.map +1 -0
  28. package/dist/_exports/http/helpers.d.ts +3 -0
  29. package/dist/_exports/http/helpers.d.ts.map +1 -0
  30. package/dist/_exports/http/helpers.js +5 -0
  31. package/dist/_exports/http/helpers.js.map +1 -0
  32. package/dist/_exports/http/request.d.ts +4 -0
  33. package/dist/_exports/http/request.d.ts.map +1 -0
  34. package/dist/_exports/http/request.js +10 -0
  35. package/dist/_exports/http/request.js.map +1 -0
  36. package/dist/_exports/i2c.d.ts +2 -0
  37. package/dist/_exports/i2c.d.ts.map +1 -0
  38. package/dist/_exports/i2c.js +2 -0
  39. package/dist/_exports/i2c.js.map +1 -0
  40. package/dist/_exports/index.d.ts +61 -0
  41. package/dist/_exports/index.d.ts.map +1 -0
  42. package/dist/_exports/index.js +4 -0
  43. package/dist/_exports/index.js.map +1 -0
  44. package/dist/_exports/inspect.d.ts +2 -0
  45. package/dist/_exports/inspect.d.ts.map +1 -0
  46. package/dist/_exports/inspect.js +2 -0
  47. package/dist/_exports/inspect.js.map +1 -0
  48. package/dist/_exports/kv/nvs.d.ts +3 -0
  49. package/dist/_exports/kv/nvs.d.ts.map +1 -0
  50. package/dist/_exports/kv/nvs.js +2 -0
  51. package/dist/_exports/kv/nvs.js.map +1 -0
  52. package/dist/_exports/kv/rtc.d.ts +3 -0
  53. package/dist/_exports/kv/rtc.d.ts.map +1 -0
  54. package/dist/_exports/kv/rtc.js +2 -0
  55. package/dist/_exports/kv/rtc.js.map +1 -0
  56. package/dist/_exports/neopixel.d.ts +2 -0
  57. package/dist/_exports/neopixel.d.ts.map +1 -0
  58. package/dist/_exports/neopixel.js +2 -0
  59. package/dist/_exports/neopixel.js.map +1 -0
  60. package/dist/_exports/pin.d.ts +2 -0
  61. package/dist/_exports/pin.d.ts.map +1 -0
  62. package/dist/_exports/pin.js +2 -0
  63. package/dist/_exports/pin.js.map +1 -0
  64. package/dist/_exports/pwm.d.ts +2 -0
  65. package/dist/_exports/pwm.d.ts.map +1 -0
  66. package/dist/_exports/pwm.js +2 -0
  67. package/dist/_exports/pwm.js.map +1 -0
  68. package/dist/_exports/reader.d.ts +2 -0
  69. package/dist/_exports/reader.d.ts.map +1 -0
  70. package/dist/_exports/reader.js +2 -0
  71. package/dist/_exports/reader.js.map +1 -0
  72. package/dist/_exports/result.d.ts +2 -0
  73. package/dist/_exports/result.d.ts.map +1 -0
  74. package/dist/_exports/result.js +2 -0
  75. package/dist/_exports/result.js.map +1 -0
  76. package/dist/_exports/schema.d.ts +2 -0
  77. package/dist/_exports/schema.d.ts.map +1 -0
  78. package/dist/_exports/schema.js +2 -0
  79. package/dist/_exports/schema.js.map +1 -0
  80. package/dist/_exports/sim.d.ts +199 -0
  81. package/dist/_exports/sim.d.ts.map +1 -0
  82. package/dist/_exports/sim.js +8 -0
  83. package/dist/_exports/sim.js.map +1 -0
  84. package/dist/_exports/sleep.d.ts +2 -0
  85. package/dist/_exports/sleep.d.ts.map +1 -0
  86. package/dist/_exports/sleep.js +2 -0
  87. package/dist/_exports/sleep.js.map +1 -0
  88. package/dist/_exports/sntp.d.ts +3 -0
  89. package/dist/_exports/sntp.d.ts.map +1 -0
  90. package/dist/_exports/sntp.js +2 -0
  91. package/dist/_exports/sntp.js.map +1 -0
  92. package/dist/_exports/spi.d.ts +2 -0
  93. package/dist/_exports/spi.d.ts.map +1 -0
  94. package/dist/_exports/spi.js +2 -0
  95. package/dist/_exports/spi.js.map +1 -0
  96. package/dist/_exports/stdio.d.ts +2 -0
  97. package/dist/_exports/stdio.d.ts.map +1 -0
  98. package/dist/_exports/stdio.js +2 -0
  99. package/dist/_exports/stdio.js.map +1 -0
  100. package/dist/_exports/stream.d.ts +2 -0
  101. package/dist/_exports/stream.d.ts.map +1 -0
  102. package/dist/_exports/stream.js +2 -0
  103. package/dist/_exports/stream.js.map +1 -0
  104. package/dist/_exports/sys.d.ts +2 -0
  105. package/dist/_exports/sys.d.ts.map +1 -0
  106. package/dist/_exports/sys.js +2 -0
  107. package/dist/_exports/sys.js.map +1 -0
  108. package/dist/_exports/test.d.ts +2 -0
  109. package/dist/_exports/test.d.ts.map +1 -0
  110. package/dist/_exports/test.js +2 -0
  111. package/dist/_exports/test.js.map +1 -0
  112. package/dist/_exports/uart.d.ts +2 -0
  113. package/dist/_exports/uart.d.ts.map +1 -0
  114. package/dist/_exports/uart.js +2 -0
  115. package/dist/_exports/uart.js.map +1 -0
  116. package/dist/_exports/wifi.d.ts +3 -0
  117. package/dist/_exports/wifi.d.ts.map +1 -0
  118. package/dist/_exports/wifi.js +2 -0
  119. package/dist/_exports/wifi.js.map +1 -0
  120. package/dist/cli/cli.d.ts +3 -0
  121. package/dist/cli/cli.d.ts.map +1 -0
  122. package/dist/cli/cli.js +215 -0
  123. package/dist/cli/cli.js.map +1 -0
  124. package/dist/cli/cliWrapper.d.ts +3 -0
  125. package/dist/cli/cliWrapper.d.ts.map +1 -0
  126. package/dist/cli/cliWrapper.js +40 -0
  127. package/dist/cli/cliWrapper.js.map +1 -0
  128. package/dist/cli/commands/build-runtime.d.ts +14 -0
  129. package/dist/cli/commands/build-runtime.d.ts.map +1 -0
  130. package/dist/cli/commands/build-runtime.js +122 -0
  131. package/dist/cli/commands/build-runtime.js.map +1 -0
  132. package/dist/cli/commands/build.d.ts +31 -0
  133. package/dist/cli/commands/build.d.ts.map +1 -0
  134. package/dist/cli/commands/build.js +145 -0
  135. package/dist/cli/commands/build.js.map +1 -0
  136. package/dist/cli/commands/clean.d.ts +16 -0
  137. package/dist/cli/commands/clean.d.ts.map +1 -0
  138. package/dist/cli/commands/clean.js +148 -0
  139. package/dist/cli/commands/clean.js.map +1 -0
  140. package/dist/cli/commands/console.d.ts +19 -0
  141. package/dist/cli/commands/console.d.ts.map +1 -0
  142. package/dist/cli/commands/console.js +32 -0
  143. package/dist/cli/commands/console.js.map +1 -0
  144. package/dist/cli/commands/deploy.d.ts +63 -0
  145. package/dist/cli/commands/deploy.d.ts.map +1 -0
  146. package/dist/cli/commands/deploy.js +242 -0
  147. package/dist/cli/commands/deploy.js.map +1 -0
  148. package/dist/cli/commands/dev.d.ts +41 -0
  149. package/dist/cli/commands/dev.d.ts.map +1 -0
  150. package/dist/cli/commands/dev.js +170 -0
  151. package/dist/cli/commands/dev.js.map +1 -0
  152. package/dist/cli/commands/docs.d.ts +7 -0
  153. package/dist/cli/commands/docs.d.ts.map +1 -0
  154. package/dist/cli/commands/docs.js +20 -0
  155. package/dist/cli/commands/docs.js.map +1 -0
  156. package/dist/cli/commands/env.d.ts +59 -0
  157. package/dist/cli/commands/env.d.ts.map +1 -0
  158. package/dist/cli/commands/env.js +257 -0
  159. package/dist/cli/commands/env.js.map +1 -0
  160. package/dist/cli/commands/erase.d.ts +18 -0
  161. package/dist/cli/commands/erase.d.ts.map +1 -0
  162. package/dist/cli/commands/erase.js +90 -0
  163. package/dist/cli/commands/erase.js.map +1 -0
  164. package/dist/cli/commands/flash.d.ts +30 -0
  165. package/dist/cli/commands/flash.d.ts.map +1 -0
  166. package/dist/cli/commands/flash.js +243 -0
  167. package/dist/cli/commands/flash.js.map +1 -0
  168. package/dist/cli/commands/home.d.ts +7 -0
  169. package/dist/cli/commands/home.d.ts.map +1 -0
  170. package/dist/cli/commands/home.js +20 -0
  171. package/dist/cli/commands/home.js.map +1 -0
  172. package/dist/cli/commands/ls.d.ts +17 -0
  173. package/dist/cli/commands/ls.d.ts.map +1 -0
  174. package/dist/cli/commands/ls.js +62 -0
  175. package/dist/cli/commands/ls.js.map +1 -0
  176. package/dist/cli/commands/sim/clean.d.ts +7 -0
  177. package/dist/cli/commands/sim/clean.d.ts.map +1 -0
  178. package/dist/cli/commands/sim/clean.js +34 -0
  179. package/dist/cli/commands/sim/clean.js.map +1 -0
  180. package/dist/cli/commands/sim/deploy.d.ts +46 -0
  181. package/dist/cli/commands/sim/deploy.d.ts.map +1 -0
  182. package/dist/cli/commands/sim/deploy.js +127 -0
  183. package/dist/cli/commands/sim/deploy.js.map +1 -0
  184. package/dist/cli/commands/sim/dev.d.ts +52 -0
  185. package/dist/cli/commands/sim/dev.d.ts.map +1 -0
  186. package/dist/cli/commands/sim/dev.js +380 -0
  187. package/dist/cli/commands/sim/dev.js.map +1 -0
  188. package/dist/cli/commands/sim/env.d.ts +56 -0
  189. package/dist/cli/commands/sim/env.d.ts.map +1 -0
  190. package/dist/cli/commands/sim/env.js +204 -0
  191. package/dist/cli/commands/sim/env.js.map +1 -0
  192. package/dist/cli/commands/sim/profile.d.ts +67 -0
  193. package/dist/cli/commands/sim/profile.d.ts.map +1 -0
  194. package/dist/cli/commands/sim/profile.js +356 -0
  195. package/dist/cli/commands/sim/profile.js.map +1 -0
  196. package/dist/cli/commands/sim/repl.d.ts +16 -0
  197. package/dist/cli/commands/sim/repl.d.ts.map +1 -0
  198. package/dist/cli/commands/sim/repl.js +119 -0
  199. package/dist/cli/commands/sim/repl.js.map +1 -0
  200. package/dist/cli/commands/sim/reset.d.ts +11 -0
  201. package/dist/cli/commands/sim/reset.d.ts.map +1 -0
  202. package/dist/cli/commands/sim/reset.js +59 -0
  203. package/dist/cli/commands/sim/reset.js.map +1 -0
  204. package/dist/cli/commands/sim/scaffold.d.ts +11 -0
  205. package/dist/cli/commands/sim/scaffold.d.ts.map +1 -0
  206. package/dist/cli/commands/sim/scaffold.js +41 -0
  207. package/dist/cli/commands/sim/scaffold.js.map +1 -0
  208. package/dist/cli/commands/sim/test.d.ts +49 -0
  209. package/dist/cli/commands/sim/test.d.ts.map +1 -0
  210. package/dist/cli/commands/sim/test.js +364 -0
  211. package/dist/cli/commands/sim/test.js.map +1 -0
  212. package/dist/cli/commands/sim.d.ts +228 -0
  213. package/dist/cli/commands/sim.d.ts.map +1 -0
  214. package/dist/cli/commands/sim.js +69 -0
  215. package/dist/cli/commands/sim.js.map +1 -0
  216. package/dist/cli/commands/tail.d.ts +14 -0
  217. package/dist/cli/commands/tail.d.ts.map +1 -0
  218. package/dist/cli/commands/tail.js +50 -0
  219. package/dist/cli/commands/tail.js.map +1 -0
  220. package/dist/cli/commands/test.d.ts +39 -0
  221. package/dist/cli/commands/test.d.ts.map +1 -0
  222. package/dist/cli/commands/test.js +432 -0
  223. package/dist/cli/commands/test.js.map +1 -0
  224. package/dist/cli/components/DevicePicker.d.ts +9 -0
  225. package/dist/cli/components/DevicePicker.d.ts.map +1 -0
  226. package/dist/cli/components/DevicePicker.js +71 -0
  227. package/dist/cli/components/DevicePicker.js.map +1 -0
  228. package/dist/cli/components/EnvEditor.d.ts +12 -0
  229. package/dist/cli/components/EnvEditor.d.ts.map +1 -0
  230. package/dist/cli/components/EnvEditor.js +201 -0
  231. package/dist/cli/components/EnvEditor.js.map +1 -0
  232. package/dist/cli/components/TextInput.d.ts +28 -0
  233. package/dist/cli/components/TextInput.d.ts.map +1 -0
  234. package/dist/cli/components/TextInput.js +73 -0
  235. package/dist/cli/components/TextInput.js.map +1 -0
  236. package/dist/cli/components/TitledBox.d.ts +27 -0
  237. package/dist/cli/components/TitledBox.d.ts.map +1 -0
  238. package/dist/cli/components/TitledBox.js +111 -0
  239. package/dist/cli/components/TitledBox.js.map +1 -0
  240. package/dist/cli/hooks/useDevices.d.ts +23 -0
  241. package/dist/cli/hooks/useDevices.d.ts.map +1 -0
  242. package/dist/cli/hooks/useDevices.js +19 -0
  243. package/dist/cli/hooks/useDevices.js.map +1 -0
  244. package/dist/cli/lib/RenderAndExit.d.ts +6 -0
  245. package/dist/cli/lib/RenderAndExit.d.ts.map +1 -0
  246. package/dist/cli/lib/RenderAndExit.js +8 -0
  247. package/dist/cli/lib/RenderAndExit.js.map +1 -0
  248. package/dist/cli/lib/Spinner.d.ts +11 -0
  249. package/dist/cli/lib/Spinner.d.ts.map +1 -0
  250. package/dist/cli/lib/Spinner.js +22 -0
  251. package/dist/cli/lib/Spinner.js.map +1 -0
  252. package/dist/cli/lib/agent.d.ts +38 -0
  253. package/dist/cli/lib/agent.d.ts.map +1 -0
  254. package/dist/cli/lib/agent.js +87 -0
  255. package/dist/cli/lib/agent.js.map +1 -0
  256. package/dist/cli/lib/boards.d.ts +23 -0
  257. package/dist/cli/lib/boards.d.ts.map +1 -0
  258. package/dist/cli/lib/boards.js +67 -0
  259. package/dist/cli/lib/boards.js.map +1 -0
  260. package/dist/cli/lib/build.d.ts +47 -0
  261. package/dist/cli/lib/build.d.ts.map +1 -0
  262. package/dist/cli/lib/build.js +533 -0
  263. package/dist/cli/lib/build.js.map +1 -0
  264. package/dist/cli/lib/connectSim.d.ts +21 -0
  265. package/dist/cli/lib/connectSim.d.ts.map +1 -0
  266. package/dist/cli/lib/connectSim.js +20 -0
  267. package/dist/cli/lib/connectSim.js.map +1 -0
  268. package/dist/cli/lib/deploy.d.ts +42 -0
  269. package/dist/cli/lib/deploy.d.ts.map +1 -0
  270. package/dist/cli/lib/deploy.js +121 -0
  271. package/dist/cli/lib/deploy.js.map +1 -0
  272. package/dist/cli/lib/deployProgress.d.ts +8 -0
  273. package/dist/cli/lib/deployProgress.d.ts.map +1 -0
  274. package/dist/cli/lib/deployProgress.js +32 -0
  275. package/dist/cli/lib/deployProgress.js.map +1 -0
  276. package/dist/cli/lib/dotenv.d.ts +16 -0
  277. package/dist/cli/lib/dotenv.d.ts.map +1 -0
  278. package/dist/cli/lib/dotenv.js +33 -0
  279. package/dist/cli/lib/dotenv.js.map +1 -0
  280. package/dist/cli/lib/esbuild.d.ts +7 -0
  281. package/dist/cli/lib/esbuild.d.ts.map +1 -0
  282. package/dist/cli/lib/esbuild.js +15 -0
  283. package/dist/cli/lib/esbuild.js.map +1 -0
  284. package/dist/cli/lib/esptool.d.ts +41 -0
  285. package/dist/cli/lib/esptool.d.ts.map +1 -0
  286. package/dist/cli/lib/esptool.js +43 -0
  287. package/dist/cli/lib/esptool.js.map +1 -0
  288. package/dist/cli/lib/firmware.d.ts +24 -0
  289. package/dist/cli/lib/firmware.d.ts.map +1 -0
  290. package/dist/cli/lib/firmware.js +406 -0
  291. package/dist/cli/lib/firmware.js.map +1 -0
  292. package/dist/cli/lib/firmwareCompat.d.ts +19 -0
  293. package/dist/cli/lib/firmwareCompat.d.ts.map +1 -0
  294. package/dist/cli/lib/firmwareCompat.js +31 -0
  295. package/dist/cli/lib/firmwareCompat.js.map +1 -0
  296. package/dist/cli/lib/heapBaseline.d.ts +15 -0
  297. package/dist/cli/lib/heapBaseline.d.ts.map +1 -0
  298. package/dist/cli/lib/heapBaseline.js +39 -0
  299. package/dist/cli/lib/heapBaseline.js.map +1 -0
  300. package/dist/cli/lib/ink-table/index.d.ts +88 -0
  301. package/dist/cli/lib/ink-table/index.d.ts.map +1 -0
  302. package/dist/cli/lib/ink-table/index.js +217 -0
  303. package/dist/cli/lib/ink-table/index.js.map +1 -0
  304. package/dist/cli/lib/loadMikroConfig.d.ts +7 -0
  305. package/dist/cli/lib/loadMikroConfig.d.ts.map +1 -0
  306. package/dist/cli/lib/loadMikroConfig.js +26 -0
  307. package/dist/cli/lib/loadMikroConfig.js.map +1 -0
  308. package/dist/cli/lib/minify.d.ts +3 -0
  309. package/dist/cli/lib/minify.d.ts.map +1 -0
  310. package/dist/cli/lib/minify.js +89 -0
  311. package/dist/cli/lib/minify.js.map +1 -0
  312. package/dist/cli/lib/openSim.d.ts +29 -0
  313. package/dist/cli/lib/openSim.d.ts.map +1 -0
  314. package/dist/cli/lib/openSim.js +32 -0
  315. package/dist/cli/lib/openSim.js.map +1 -0
  316. package/dist/cli/lib/ospawn.d.ts +34 -0
  317. package/dist/cli/lib/ospawn.d.ts.map +1 -0
  318. package/dist/cli/lib/ospawn.js +90 -0
  319. package/dist/cli/lib/ospawn.js.map +1 -0
  320. package/dist/cli/lib/parseMinifier.d.ts +10 -0
  321. package/dist/cli/lib/parseMinifier.d.ts.map +1 -0
  322. package/dist/cli/lib/parseMinifier.js +49 -0
  323. package/dist/cli/lib/parseMinifier.js.map +1 -0
  324. package/dist/cli/lib/parseSize.d.ts +6 -0
  325. package/dist/cli/lib/parseSize.d.ts.map +1 -0
  326. package/dist/cli/lib/parseSize.js +25 -0
  327. package/dist/cli/lib/parseSize.js.map +1 -0
  328. package/dist/cli/lib/projectRoot.d.ts +11 -0
  329. package/dist/cli/lib/projectRoot.d.ts.map +1 -0
  330. package/dist/cli/lib/projectRoot.js +28 -0
  331. package/dist/cli/lib/projectRoot.js.map +1 -0
  332. package/dist/cli/lib/protocol.d.ts +144 -0
  333. package/dist/cli/lib/protocol.d.ts.map +1 -0
  334. package/dist/cli/lib/protocol.js +385 -0
  335. package/dist/cli/lib/protocol.js.map +1 -0
  336. package/dist/cli/lib/recover.d.ts +25 -0
  337. package/dist/cli/lib/recover.d.ts.map +1 -0
  338. package/dist/cli/lib/recover.js +144 -0
  339. package/dist/cli/lib/recover.js.map +1 -0
  340. package/dist/cli/lib/resolveEntry.d.ts +7 -0
  341. package/dist/cli/lib/resolveEntry.d.ts.map +1 -0
  342. package/dist/cli/lib/resolveEntry.js +30 -0
  343. package/dist/cli/lib/resolveEntry.js.map +1 -0
  344. package/dist/cli/lib/runHooks.d.ts +34 -0
  345. package/dist/cli/lib/runHooks.d.ts.map +1 -0
  346. package/dist/cli/lib/runHooks.js +90 -0
  347. package/dist/cli/lib/runHooks.js.map +1 -0
  348. package/dist/cli/lib/serial/InkReplConsole.d.ts +27 -0
  349. package/dist/cli/lib/serial/InkReplConsole.d.ts.map +1 -0
  350. package/dist/cli/lib/serial/InkReplConsole.js +24 -0
  351. package/dist/cli/lib/serial/InkReplConsole.js.map +1 -0
  352. package/dist/cli/lib/serial/InkReplMode.d.ts +38 -0
  353. package/dist/cli/lib/serial/InkReplMode.d.ts.map +1 -0
  354. package/dist/cli/lib/serial/InkReplMode.js +90 -0
  355. package/dist/cli/lib/serial/InkReplMode.js.map +1 -0
  356. package/dist/cli/lib/serial/ReplConsole.d.ts +21 -0
  357. package/dist/cli/lib/serial/ReplConsole.d.ts.map +1 -0
  358. package/dist/cli/lib/serial/ReplConsole.js +249 -0
  359. package/dist/cli/lib/serial/ReplConsole.js.map +1 -0
  360. package/dist/cli/lib/serial/devSession.d.ts +57 -0
  361. package/dist/cli/lib/serial/devSession.d.ts.map +1 -0
  362. package/dist/cli/lib/serial/devSession.js +160 -0
  363. package/dist/cli/lib/serial/devSession.js.map +1 -0
  364. package/dist/cli/lib/serial/dispatchReplCommand.d.ts +25 -0
  365. package/dist/cli/lib/serial/dispatchReplCommand.d.ts.map +1 -0
  366. package/dist/cli/lib/serial/dispatchReplCommand.js +27 -0
  367. package/dist/cli/lib/serial/dispatchReplCommand.js.map +1 -0
  368. package/dist/cli/lib/serial/openSession.d.ts +28 -0
  369. package/dist/cli/lib/serial/openSession.d.ts.map +1 -0
  370. package/dist/cli/lib/serial/openSession.js +48 -0
  371. package/dist/cli/lib/serial/openSession.js.map +1 -0
  372. package/dist/cli/lib/serial/replStateMachine.d.ts +169 -0
  373. package/dist/cli/lib/serial/replStateMachine.d.ts.map +1 -0
  374. package/dist/cli/lib/serial/replStateMachine.js +657 -0
  375. package/dist/cli/lib/serial/replStateMachine.js.map +1 -0
  376. package/dist/cli/lib/serial/runAgentRepl.d.ts +33 -0
  377. package/dist/cli/lib/serial/runAgentRepl.d.ts.map +1 -0
  378. package/dist/cli/lib/serial/runAgentRepl.js +80 -0
  379. package/dist/cli/lib/serial/runAgentRepl.js.map +1 -0
  380. package/dist/cli/lib/session.d.ts +163 -0
  381. package/dist/cli/lib/session.d.ts.map +1 -0
  382. package/dist/cli/lib/session.js +490 -0
  383. package/dist/cli/lib/session.js.map +1 -0
  384. package/dist/cli/lib/simConfig.d.ts +15 -0
  385. package/dist/cli/lib/simConfig.d.ts.map +1 -0
  386. package/dist/cli/lib/simConfig.js +25 -0
  387. package/dist/cli/lib/simConfig.js.map +1 -0
  388. package/dist/cli/lib/simPid.d.ts +30 -0
  389. package/dist/cli/lib/simPid.d.ts.map +1 -0
  390. package/dist/cli/lib/simPid.js +120 -0
  391. package/dist/cli/lib/simPid.js.map +1 -0
  392. package/dist/cli/lib/simTransport.d.ts +17 -0
  393. package/dist/cli/lib/simTransport.d.ts.map +1 -0
  394. package/dist/cli/lib/simTransport.js +80 -0
  395. package/dist/cli/lib/simTransport.js.map +1 -0
  396. package/dist/cli/lib/testRunner.d.ts +86 -0
  397. package/dist/cli/lib/testRunner.d.ts.map +1 -0
  398. package/dist/cli/lib/testRunner.js +469 -0
  399. package/dist/cli/lib/testRunner.js.map +1 -0
  400. package/dist/cli/lib/transport.d.ts +34 -0
  401. package/dist/cli/lib/transport.d.ts.map +1 -0
  402. package/dist/cli/lib/transport.js +117 -0
  403. package/dist/cli/lib/transport.js.map +1 -0
  404. package/dist/cli/lib/useObservable.d.ts +4 -0
  405. package/dist/cli/lib/useObservable.d.ts.map +1 -0
  406. package/dist/cli/lib/useObservable.js +22 -0
  407. package/dist/cli/lib/useObservable.js.map +1 -0
  408. package/dist/cli/lib/watcher.d.ts +10 -0
  409. package/dist/cli/lib/watcher.d.ts.map +1 -0
  410. package/dist/cli/lib/watcher.js +34 -0
  411. package/dist/cli/lib/watcher.js.map +1 -0
  412. package/dist/constants.d.ts +13 -0
  413. package/dist/constants.d.ts.map +1 -0
  414. package/dist/constants.js +27 -0
  415. package/dist/constants.js.map +1 -0
  416. package/dist/simulator/builtins/ble.d.ts +3 -0
  417. package/dist/simulator/builtins/ble.d.ts.map +1 -0
  418. package/dist/simulator/builtins/ble.js +46 -0
  419. package/dist/simulator/builtins/ble.js.map +1 -0
  420. package/dist/simulator/builtins/console.d.ts +8 -0
  421. package/dist/simulator/builtins/console.d.ts.map +1 -0
  422. package/dist/simulator/builtins/console.js +24 -0
  423. package/dist/simulator/builtins/console.js.map +1 -0
  424. package/dist/simulator/builtins/http.d.ts +3 -0
  425. package/dist/simulator/builtins/http.d.ts.map +1 -0
  426. package/dist/simulator/builtins/http.js +90 -0
  427. package/dist/simulator/builtins/http.js.map +1 -0
  428. package/dist/simulator/builtins/i2c.d.ts +3 -0
  429. package/dist/simulator/builtins/i2c.d.ts.map +1 -0
  430. package/dist/simulator/builtins/i2c.js +17 -0
  431. package/dist/simulator/builtins/i2c.js.map +1 -0
  432. package/dist/simulator/builtins/index.d.ts +7 -0
  433. package/dist/simulator/builtins/index.d.ts.map +1 -0
  434. package/dist/simulator/builtins/index.js +49 -0
  435. package/dist/simulator/builtins/index.js.map +1 -0
  436. package/dist/simulator/builtins/kv.d.ts +3 -0
  437. package/dist/simulator/builtins/kv.d.ts.map +1 -0
  438. package/dist/simulator/builtins/kv.js +39 -0
  439. package/dist/simulator/builtins/kv.js.map +1 -0
  440. package/dist/simulator/builtins/neopixel.d.ts +3 -0
  441. package/dist/simulator/builtins/neopixel.d.ts.map +1 -0
  442. package/dist/simulator/builtins/neopixel.js +15 -0
  443. package/dist/simulator/builtins/neopixel.js.map +1 -0
  444. package/dist/simulator/builtins/nvs-kv.d.ts +3 -0
  445. package/dist/simulator/builtins/nvs-kv.d.ts.map +1 -0
  446. package/dist/simulator/builtins/nvs-kv.js +69 -0
  447. package/dist/simulator/builtins/nvs-kv.js.map +1 -0
  448. package/dist/simulator/builtins/pin.d.ts +3 -0
  449. package/dist/simulator/builtins/pin.d.ts.map +1 -0
  450. package/dist/simulator/builtins/pin.js +32 -0
  451. package/dist/simulator/builtins/pin.js.map +1 -0
  452. package/dist/simulator/builtins/pwm.d.ts +3 -0
  453. package/dist/simulator/builtins/pwm.d.ts.map +1 -0
  454. package/dist/simulator/builtins/pwm.js +31 -0
  455. package/dist/simulator/builtins/pwm.js.map +1 -0
  456. package/dist/simulator/builtins/sleep.d.ts +3 -0
  457. package/dist/simulator/builtins/sleep.d.ts.map +1 -0
  458. package/dist/simulator/builtins/sleep.js +33 -0
  459. package/dist/simulator/builtins/sleep.js.map +1 -0
  460. package/dist/simulator/builtins/sntp.d.ts +3 -0
  461. package/dist/simulator/builtins/sntp.d.ts.map +1 -0
  462. package/dist/simulator/builtins/sntp.js +14 -0
  463. package/dist/simulator/builtins/sntp.js.map +1 -0
  464. package/dist/simulator/builtins/spi.d.ts +3 -0
  465. package/dist/simulator/builtins/spi.d.ts.map +1 -0
  466. package/dist/simulator/builtins/spi.js +16 -0
  467. package/dist/simulator/builtins/spi.js.map +1 -0
  468. package/dist/simulator/builtins/types.d.ts +24 -0
  469. package/dist/simulator/builtins/types.d.ts.map +1 -0
  470. package/dist/simulator/builtins/types.js +2 -0
  471. package/dist/simulator/builtins/types.js.map +1 -0
  472. package/dist/simulator/builtins/uart.d.ts +3 -0
  473. package/dist/simulator/builtins/uart.d.ts.map +1 -0
  474. package/dist/simulator/builtins/uart.js +22 -0
  475. package/dist/simulator/builtins/uart.js.map +1 -0
  476. package/dist/simulator/builtins/wifi.d.ts +3 -0
  477. package/dist/simulator/builtins/wifi.d.ts.map +1 -0
  478. package/dist/simulator/builtins/wifi.js +55 -0
  479. package/dist/simulator/builtins/wifi.js.map +1 -0
  480. package/dist/simulator/devRunner.d.ts +41 -0
  481. package/dist/simulator/devRunner.d.ts.map +1 -0
  482. package/dist/simulator/devRunner.js +201 -0
  483. package/dist/simulator/devRunner.js.map +1 -0
  484. package/dist/simulator/loadSimStubs.d.ts +15 -0
  485. package/dist/simulator/loadSimStubs.d.ts.map +1 -0
  486. package/dist/simulator/loadSimStubs.js +54 -0
  487. package/dist/simulator/loadSimStubs.js.map +1 -0
  488. package/dist/simulator/simProcess.d.ts +11 -0
  489. package/dist/simulator/simProcess.d.ts.map +1 -0
  490. package/dist/simulator/simProcess.js +957 -0
  491. package/dist/simulator/simProcess.js.map +1 -0
  492. package/dist/simulator/simTemplates.d.ts +6 -0
  493. package/dist/simulator/simTemplates.d.ts.map +1 -0
  494. package/dist/simulator/simTemplates.js +21 -0
  495. package/dist/simulator/simTemplates.js.map +1 -0
  496. package/package.json +123 -2
  497. package/runtime.d.ts +95 -0
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Safe-mode recovery for crash-looping devices.
3
+ *
4
+ * Two independent reset paths, run back-to-back so at least one fires:
5
+ *
6
+ * 1. In-band CMD_RESTART frame. If the device is currently in the protocol
7
+ * loop (responsive, not crash-looping) the firmware handler calls
8
+ * esp_restart() and we get a clean software reset. Also handles the
9
+ * common "crash-looping but briefly responsive" case.
10
+ *
11
+ * 2. Hardware RTS/DTR reset matching esptool's HardReset(uses_usb=True).
12
+ * DTR pinned to false so IO0 stays high and the chip boots normally
13
+ * instead of entering the ROM bootloader. Covers genuinely stuck devices
14
+ * where the protocol is not responding at all.
15
+ *
16
+ * After the reset attempts, we flood the firmware's recovery sync sequence
17
+ * ("MIKSAFE\n") so mik__check_recovery() picks it up during its boot window
18
+ * and skips user-app autorun. The firmware's RTC_NOINIT_ATTR double-reset
19
+ * detection makes path 1 + path 2 firing back-to-back safe.
20
+ *
21
+ * Pairs with the firmware-side window in mik_recovery.cpp.
22
+ */
23
+ import type { SerialPort } from 'serialport';
24
+ export declare function triggerSafeMode(serial: SerialPort, floodMs?: number): Promise<void>;
25
+ //# sourceMappingURL=recover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recover.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/recover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AA0D1C,wBAAsB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA+CvF"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Safe-mode recovery for crash-looping devices.
3
+ *
4
+ * Two independent reset paths, run back-to-back so at least one fires:
5
+ *
6
+ * 1. In-band CMD_RESTART frame. If the device is currently in the protocol
7
+ * loop (responsive, not crash-looping) the firmware handler calls
8
+ * esp_restart() and we get a clean software reset. Also handles the
9
+ * common "crash-looping but briefly responsive" case.
10
+ *
11
+ * 2. Hardware RTS/DTR reset matching esptool's HardReset(uses_usb=True).
12
+ * DTR pinned to false so IO0 stays high and the chip boots normally
13
+ * instead of entering the ROM bootloader. Covers genuinely stuck devices
14
+ * where the protocol is not responding at all.
15
+ *
16
+ * After the reset attempts, we flood the firmware's recovery sync sequence
17
+ * ("MIKSAFE\n") so mik__check_recovery() picks it up during its boot window
18
+ * and skips user-app autorun. The firmware's RTC_NOINIT_ATTR double-reset
19
+ * detection makes path 1 + path 2 firing back-to-back safe.
20
+ *
21
+ * Pairs with the firmware-side window in mik_recovery.cpp.
22
+ */
23
+ import { buildRestartCommand } from './protocol.js';
24
+ const SYNC = Buffer.from('MIKSAFE\n');
25
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
26
+ const setLines = (serial, lines) => new Promise((resolve, reject) => {
27
+ serial.set(lines, (err) => (err ? reject(err) : resolve()));
28
+ });
29
+ const writeAndDrain = (serial, buf) => new Promise((resolve, reject) => {
30
+ serial.write(buf, (err) => {
31
+ if (err)
32
+ return reject(err);
33
+ serial.drain((drainErr) => (drainErr ? reject(drainErr) : resolve()));
34
+ });
35
+ });
36
+ /**
37
+ * Reset the chip and flood sync bytes during the firmware's recovery window.
38
+ *
39
+ * On USB Serial/JTAG chips the reset can briefly disconnect the USB device,
40
+ * so the RTS/DTR writes are wrapped in a retry loop that tolerates transient
41
+ * IOErrors. Matches what esptool does in ResetStrategy.__call__().
42
+ *
43
+ * @param serial - already-open SerialPort
44
+ * @param floodMs - how long to send sync bytes after reset (default 1500ms,
45
+ * wide enough to cover boot prologue + 500ms recovery window)
46
+ */
47
+ const DEBUG = process.env['MIKRO_RECOVER_DEBUG'] === '1';
48
+ function debug(msg) {
49
+ if (DEBUG)
50
+ process.stderr.write(`[recover] ${msg}\n`);
51
+ }
52
+ function debugRxListener(serial) {
53
+ if (!DEBUG)
54
+ return () => { };
55
+ const onData = (chunk) => {
56
+ const hex = chunk.toString('hex');
57
+ const ascii = chunk
58
+ .toString('latin1')
59
+ .split('')
60
+ .map((c) => {
61
+ const code = c.charCodeAt(0);
62
+ return code >= 0x20 && code < 0x7f ? c : '.';
63
+ })
64
+ .join('');
65
+ process.stderr.write(`[recover] rx ${chunk.length}B ${hex} |${ascii}|\n`);
66
+ };
67
+ serial.on('data', onData);
68
+ return () => {
69
+ serial.off('data', onData);
70
+ };
71
+ }
72
+ export async function triggerSafeMode(serial, floodMs = 1500) {
73
+ const unwatch = debugRxListener(serial);
74
+ try {
75
+ debug(`start; port=${serial.path}`);
76
+ // Path 1: in-band CMD_RESTART. If the device is in the protocol loop
77
+ // the firmware calls esp_restart() immediately. Harmless if ignored.
78
+ try {
79
+ debug('writing CMD_RESTART frame');
80
+ await writeAndDrain(serial, buildRestartCommand());
81
+ }
82
+ catch (err) {
83
+ debug(`CMD_RESTART write failed: ${err instanceof Error ? err.message : String(err)}`);
84
+ }
85
+ // Give the firmware a moment to process the restart and start rebooting
86
+ // before we pulse the hardware lines (avoids resetting mid-boot-prologue).
87
+ await sleep(100);
88
+ // Path 2: hardware RTS/DTR reset. Wrapped to tolerate IO errors since
89
+ // USB Serial/JTAG ports can briefly disconnect during reset.
90
+ try {
91
+ debug('hardware RTS/DTR reset');
92
+ await hardReset(serial);
93
+ }
94
+ catch (err) {
95
+ debug(`hardReset failed: ${err instanceof Error ? err.message : String(err)}`);
96
+ }
97
+ // Flood for the full duration. The firmware drains stdin after detecting
98
+ // the sync sequence (see mik_recovery.cpp drain_stdin), so the tail of
99
+ // the flood doesn't pollute the protocol RX buffer.
100
+ debug(`flooding sync bytes for ${floodMs}ms`);
101
+ const deadline = Date.now() + floodMs;
102
+ let sent = 0;
103
+ let failed = 0;
104
+ while (Date.now() < deadline) {
105
+ try {
106
+ await writeAndDrain(serial, SYNC);
107
+ sent++;
108
+ }
109
+ catch {
110
+ failed++;
111
+ }
112
+ await sleep(50);
113
+ }
114
+ debug(`flood done; sent=${sent} failed=${failed}`);
115
+ }
116
+ finally {
117
+ unwatch();
118
+ }
119
+ }
120
+ /**
121
+ * esptool-equivalent of HardReset(uses_usb=True). Retries on IO errors since
122
+ * the USB CDC device can briefly disappear during reset on newer ESP32 chips.
123
+ */
124
+ async function hardReset(serial) {
125
+ for (let attempt = 2; attempt >= 0; attempt--) {
126
+ try {
127
+ // Pin DTR=false throughout so IO0 stays high (app boot, not download mode).
128
+ // RTS=true → EN low (chip in reset).
129
+ await setLines(serial, { dtr: false, rts: true });
130
+ await sleep(200);
131
+ // RTS=false → EN high, chip starts booting.
132
+ await setLines(serial, { dtr: false, rts: false });
133
+ await sleep(200);
134
+ return;
135
+ }
136
+ catch (err) {
137
+ if (attempt === 0)
138
+ throw err;
139
+ // Port may have dropped out mid-reset on USB Serial/JTAG. Give it a moment.
140
+ await sleep(500);
141
+ }
142
+ }
143
+ }
144
+ //# sourceMappingURL=recover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recover.js","sourceRoot":"","sources":["../../../src/cli/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AC,oBAAoB,IAAI,WAAW,MAAM,EAAE,CAAC,CAAA;IACpD,CAAC;YAAS,CAAC;QACT,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,SAAS,CAAC,MAAkB;IACzC,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC;QAC9C,IAAI,CAAC;YACH,4EAA4E;YAC5E,qCAAqC;YACrC,MAAM,QAAQ,CAAC,MAAM,EAAE,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAC,CAAC,CAAA;YAC/C,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;YAChB,4CAA4C;YAC5C,MAAM,QAAQ,CAAC,MAAM,EAAE,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAC,CAAC,CAAA;YAChD,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;YAChB,OAAM;QACR,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,OAAO,KAAK,CAAC;gBAAE,MAAM,GAAG,CAAA;YAC5B,4EAA4E;YAC5E,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;QAClB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Resolve the entry file for a command.
3
+ * If an explicit entry is provided, return it as-is.
4
+ * Otherwise, read the `main` field from the nearest `package.json`.
5
+ */
6
+ export declare function resolveEntry(entry: string | undefined): string;
7
+ //# sourceMappingURL=resolveEntry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveEntry.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/resolveEntry.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAkC9D"}
@@ -0,0 +1,30 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import * as pathlib from 'node:path';
3
+ /**
4
+ * Resolve the entry file for a command.
5
+ * If an explicit entry is provided, return it as-is.
6
+ * Otherwise, read the `main` field from the nearest `package.json`.
7
+ */
8
+ export function resolveEntry(entry) {
9
+ if (entry !== undefined) {
10
+ return entry;
11
+ }
12
+ const cwd = process.cwd();
13
+ const pkgPath = pathlib.join(cwd, 'package.json');
14
+ if (!existsSync(pkgPath)) {
15
+ throw new Error(`No entry file specified and no package.json found in ${cwd}.\n` +
16
+ `Either pass an entry file (e.g. mikro dev app/main.ts) or add a "main" field to package.json.`);
17
+ }
18
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
19
+ const main = pkg.main;
20
+ if (typeof main !== 'string') {
21
+ throw new Error(`No entry file specified and package.json has no "main" field.\n` +
22
+ `Either pass an entry file (e.g. mikro dev app/main.ts) or add a "main" field to package.json.`);
23
+ }
24
+ const resolved = pathlib.resolve(cwd, main);
25
+ if (!existsSync(resolved)) {
26
+ throw new Error(`Entry file "${main}" (from package.json "main" field) does not exist: ${resolved}`);
27
+ }
28
+ return pathlib.relative(cwd, resolved);
29
+ }
30
+ //# sourceMappingURL=resolveEntry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveEntry.js","sourceRoot":"","sources":["../../../src/cli/lib/resolveEntry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,SAAS,CAAA;AAChD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA;AAEpC;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAyB;IACpD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IACzB,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAA;IAEjD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,wDAAwD,GAAG,KAAK;YAC9D,+FAA+F,CAClG,CAAA;IACH,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IACtD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;IAErB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CACb,iEAAiE;YAC/D,+FAA+F,CAClG,CAAA;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAE3C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,eAAe,IAAI,sDAAsD,QAAQ,EAAE,CACpF,CAAA;IACH,CAAC;IAED,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;AACxC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { Observable } from 'rxjs';
2
+ /**
3
+ * Read `mikrojs.predeploy` from the project's package.json. Returns an
4
+ * empty array if the file, the `mikrojs` field, or the `predeploy` field
5
+ * is missing. Throws on malformed `predeploy` values.
6
+ */
7
+ export declare function getPredeployCommands(projectRoot: string): string[];
8
+ export type HookEvent = {
9
+ type: 'start';
10
+ command: string;
11
+ } | {
12
+ type: 'stdout';
13
+ command: string;
14
+ chunk: Uint8Array;
15
+ } | {
16
+ type: 'stderr';
17
+ command: string;
18
+ chunk: Uint8Array;
19
+ } | {
20
+ type: 'complete';
21
+ command: string;
22
+ };
23
+ export declare class HookError extends Error {
24
+ readonly command: string;
25
+ readonly exitCode: number | null;
26
+ readonly signal: NodeJS.Signals | null;
27
+ constructor(command: string, exitCode: number | null, signal: NodeJS.Signals | null);
28
+ }
29
+ /**
30
+ * Run `commands` sequentially, fail-fast. Unsubscribe cancels the in-flight
31
+ * hook (via AbortController) and skips the rest.
32
+ */
33
+ export declare function runHooks(commands: readonly string[], cwd: string): Observable<HookEvent>;
34
+ //# sourceMappingURL=runHooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runHooks.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/runHooks.ts"],"names":[],"mappings":"AAIA,OAAO,EAAS,UAAU,EAAC,MAAM,MAAM,CAAA;AAEvC;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAclE;AAED,MAAM,MAAM,SAAS,GACjB;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,GAChC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAC,GACpD;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAC,GACpD;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAA;AAEvC,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA;gBAE1B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI;CAOpF;AA8CD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,CAExF"}
@@ -0,0 +1,90 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { readFileSync } from 'node:fs';
3
+ import * as pathlib from 'node:path';
4
+ import { concat, Observable } from 'rxjs';
5
+ /**
6
+ * Read `mikrojs.predeploy` from the project's package.json. Returns an
7
+ * empty array if the file, the `mikrojs` field, or the `predeploy` field
8
+ * is missing. Throws on malformed `predeploy` values.
9
+ */
10
+ export function getPredeployCommands(projectRoot) {
11
+ const path = pathlib.join(projectRoot, 'package.json');
12
+ let raw;
13
+ try {
14
+ raw = readFileSync(path, 'utf-8');
15
+ }
16
+ catch {
17
+ return [];
18
+ }
19
+ const pkg = JSON.parse(raw);
20
+ const value = pkg.mikrojs?.predeploy;
21
+ if (value === undefined || value === null)
22
+ return [];
23
+ if (typeof value === 'string')
24
+ return [value];
25
+ if (Array.isArray(value) && value.every((v) => typeof v === 'string'))
26
+ return value;
27
+ throw new Error('Invalid mikrojs.predeploy in package.json: expected string or array of strings');
28
+ }
29
+ export class HookError extends Error {
30
+ command;
31
+ exitCode;
32
+ signal;
33
+ constructor(command, exitCode, signal) {
34
+ const detail = signal ? `signal ${signal}` : `exit ${exitCode}`;
35
+ super(`Hook failed: ${command} (${detail})`);
36
+ this.command = command;
37
+ this.exitCode = exitCode;
38
+ this.signal = signal;
39
+ }
40
+ }
41
+ function runHook(command, cwd) {
42
+ return new Observable((subscriber) => {
43
+ const abort = new AbortController();
44
+ // Prepend <projectRoot>/node_modules/.bin so `tsc`, `eslint`, etc.
45
+ // resolve without requiring `npx` / `pnpm exec` in the command string.
46
+ const binDir = pathlib.join(cwd, 'node_modules', '.bin');
47
+ const env = { ...process.env, PATH: `${binDir}${pathlib.delimiter}${process.env.PATH ?? ''}` };
48
+ subscriber.next({ type: 'start', command });
49
+ const child = spawn(command, {
50
+ shell: true,
51
+ cwd,
52
+ env,
53
+ signal: abort.signal,
54
+ stdio: ['ignore', 'pipe', 'pipe'],
55
+ });
56
+ child.stdout?.on('data', (chunk) => {
57
+ subscriber.next({ type: 'stdout', command, chunk });
58
+ });
59
+ child.stderr?.on('data', (chunk) => {
60
+ subscriber.next({ type: 'stderr', command, chunk });
61
+ });
62
+ child.on('error', (err) => {
63
+ if (abort.signal.aborted)
64
+ return;
65
+ subscriber.error(err);
66
+ });
67
+ child.on('close', (code, signal) => {
68
+ if (abort.signal.aborted)
69
+ return;
70
+ if (code === 0) {
71
+ subscriber.next({ type: 'complete', command });
72
+ subscriber.complete();
73
+ }
74
+ else {
75
+ subscriber.error(new HookError(command, code, signal));
76
+ }
77
+ });
78
+ return () => {
79
+ abort.abort();
80
+ };
81
+ });
82
+ }
83
+ /**
84
+ * Run `commands` sequentially, fail-fast. Unsubscribe cancels the in-flight
85
+ * hook (via AbortController) and skips the rest.
86
+ */
87
+ export function runHooks(commands, cwd) {
88
+ return concat(...commands.map((cmd) => runHook(cmd, cwd)));
89
+ }
90
+ //# sourceMappingURL=runHooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runHooks.js","sourceRoot":"","sources":["../../../src/cli/lib/runHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAA;AACpC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA;AAEpC,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,MAAM,CAAA;AAEvC;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAmB;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAA;IACtD,IAAI,GAAW,CAAA;IACf,IAAI,CAAC;QACH,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAsC,CAAA;IAChE,MAAM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AAC,CAAC,CAAA;gBAC5C,UAAU,CAAC,QAAQ,EAAE,CAAA;YACvB,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;YACxD,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,GAAG,EAAE;YACV,KAAK,CAAC,KAAK,EAAE,CAAA;QACf,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,QAA2B,EAAE,GAAW;IAC/D,OAAO,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;AAC5D,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { LogLevel } from '../../../_exports/index.js';
2
+ import type { ReplSession } from '../session.js';
3
+ import { type ReplHandle } from './replStateMachine.js';
4
+ export interface InkReplConsoleProps {
5
+ session: ReplSession;
6
+ devicePath: string;
7
+ logLevel?: LogLevel;
8
+ /** When true, the deploy keybind fires a trigger into the repl's
9
+ * `deploys$`. Defaults to false so callers that render a plain REPL
10
+ * (e.g. `deploy --console`) don't accidentally emit into a Subject
11
+ * no one subscribes to. `InkReplMode` sets this to `true` when a
12
+ * `driver` is supplied. */
13
+ deployEnabled?: boolean;
14
+ /** Pre-built repl handle. Use when the caller already created the repl
15
+ * (e.g. to subscribe to its `deploys$` before handing it off). */
16
+ repl?: ReplHandle;
17
+ /** Forwarded to `ReplConsole` for the header watch-mode badge. */
18
+ watch?: boolean;
19
+ }
20
+ /**
21
+ * Renders a `ReplConsole` over an existing `ReplSession`. Owns the
22
+ * Kitty-keyboard cleanup (`\x1b[<u`) and `process.exit(0)` on end.
23
+ * Pure in the sense that it doesn't touch the serial port or open
24
+ * a connection — feed it a live session.
25
+ */
26
+ export declare function InkReplConsole(props: InkReplConsoleProps): import("react/jsx-runtime").JSX.Element;
27
+ //# sourceMappingURL=InkReplConsole.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkReplConsole.d.ts","sourceRoot":"","sources":["../../../../src/cli/lib/serial/InkReplConsole.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,4BAA4B,CAAA;AACxD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,eAAe,CAAA;AAE9C,OAAO,EAAa,KAAK,UAAU,EAAC,MAAM,uBAAuB,CAAA;AAEjE,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,WAAW,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB;;;;gCAI4B;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;uEACmE;IACnE,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,kEAAkE;IAClE,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,2CAcxD"}
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback, useMemo } from 'react';
3
+ import { ReplConsole } from './ReplConsole.js';
4
+ import { createRepl } from './replStateMachine.js';
5
+ /**
6
+ * Renders a `ReplConsole` over an existing `ReplSession`. Owns the
7
+ * Kitty-keyboard cleanup (`\x1b[<u`) and `process.exit(0)` on end.
8
+ * Pure in the sense that it doesn't touch the serial port or open
9
+ * a connection — feed it a live session.
10
+ */
11
+ export function InkReplConsole(props) {
12
+ const { session, devicePath, logLevel, deployEnabled = false, repl: providedRepl, watch } = props;
13
+ const handleEnd = useCallback(() => {
14
+ process.stdout.write('\x1b[<u');
15
+ process.exit(0);
16
+ }, []);
17
+ const repl = useMemo(() => {
18
+ if (providedRepl)
19
+ return providedRepl;
20
+ return createRepl({ session, port: devicePath, onEnd: handleEnd, deployEnabled });
21
+ }, [providedRepl, session, devicePath, handleEnd, deployEnabled]);
22
+ return _jsx(ReplConsole, { repl: repl, config: session.config, logLevel: logLevel, watch: watch });
23
+ }
24
+ //# sourceMappingURL=InkReplConsole.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkReplConsole.js","sourceRoot":"","sources":["../../../../src/cli/lib/serial/InkReplConsole.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,OAAO,CAAA;AAI1C,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAC,UAAU,EAAkB,MAAM,uBAAuB,CAAA;AAmBjE;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,EAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,GAAG,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAC,GAAG,KAAK,CAAA;IAE/F,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE;QACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE;QACxB,IAAI,YAAY;YAAE,OAAO,YAAY,CAAA;QACrC,OAAO,UAAU,CAAC,EAAC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAC,CAAC,CAAA;IACjF,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAA;IAEjE,OAAO,KAAC,WAAW,IAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAI,CAAA;AAC9F,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { type Observable } from 'rxjs';
2
+ import type { LogLevel } from '../../../_exports/index.js';
3
+ import { type ReplSession } from '../session.js';
4
+ import { type ReplHandle } from './replStateMachine.js';
5
+ export interface InkReplDriverContext {
6
+ session: ReplSession;
7
+ repl: ReplHandle;
8
+ devicePath: string;
9
+ }
10
+ export interface InkReplDriverResult {
11
+ /** Observable to subscribe to for the session's lifetime. Used by `dev`
12
+ * to keep `createDevSession.state$` alive. */
13
+ run$?: Observable<unknown>;
14
+ /** Cleanup ran when the component unmounts. */
15
+ dispose?: () => void;
16
+ }
17
+ export interface InkReplModeProps {
18
+ devicePath: string;
19
+ /** Trigger safe-mode after opening the session. Used by
20
+ * `console --recover` / `deploy --recover`. */
21
+ recover?: boolean;
22
+ logLevel?: LogLevel;
23
+ /** Per-command work that runs alongside the REPL. When a driver is
24
+ * supplied, Ctrl+S is wired up (callers typically subscribe to
25
+ * `repl.deploys$`). Without a driver, the deploy keybind is a no-op. */
26
+ driver?: (ctx: InkReplDriverContext) => InkReplDriverResult;
27
+ /** Forwarded to the rendered `ReplConsole` header badge. Typically set
28
+ * by `dev` to reflect `--no-watch`. */
29
+ watch?: boolean;
30
+ }
31
+ /**
32
+ * Shared Ink-mode orchestrator for `dev`, `console`, and any command
33
+ * that wants "connect + attach REPL". Opens the serial, brings up a
34
+ * `ReplSession`, creates a `ReplHandle`, runs the optional `driver`
35
+ * for the session's lifetime, and renders `InkReplConsole`.
36
+ */
37
+ export declare function InkReplMode(props: InkReplModeProps): import("react/jsx-runtime").JSX.Element;
38
+ //# sourceMappingURL=InkReplMode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkReplMode.d.ts","sourceRoot":"","sources":["../../../../src/cli/lib/serial/InkReplMode.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAwB,KAAK,UAAU,EAA6B,MAAM,MAAM,CAAA;AAEvF,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,4BAA4B,CAAA;AAGxD,OAAO,EAAc,KAAK,WAAW,EAAC,MAAM,eAAe,CAAA;AAK3D,OAAO,EAAa,KAAK,UAAU,EAAC,MAAM,uBAAuB,CAAA;AAEjE,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,WAAW,CAAA;IACpB,IAAI,EAAE,UAAU,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC;mDAC+C;IAC/C,IAAI,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IAC1B,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB;oDACgD;IAChD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB;;6EAEyE;IACzE,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,KAAK,mBAAmB,CAAA;IAC3D;4CACwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,2CAgGlD"}
@@ -0,0 +1,90 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import spinners from 'cli-spinners';
3
+ import { Text, useInput } from 'ink';
4
+ import { useCallback, useEffect, useMemo, useRef } from 'react';
5
+ import { catchError, from, map, of, shareReplay, switchMap } from 'rxjs';
6
+ import { BAUD_RATE } from '../deploy.js';
7
+ import { triggerSafeMode } from '../recover.js';
8
+ import { connectRepl } from '../session.js';
9
+ import { Spinner } from '../Spinner.js';
10
+ import { createSerialTransport, openSerial } from '../transport.js';
11
+ import { useObservable } from '../useObservable.js';
12
+ import { InkReplConsole } from './InkReplConsole.js';
13
+ import { createRepl } from './replStateMachine.js';
14
+ /**
15
+ * Shared Ink-mode orchestrator for `dev`, `console`, and any command
16
+ * that wants "connect + attach REPL". Opens the serial, brings up a
17
+ * `ReplSession`, creates a `ReplHandle`, runs the optional `driver`
18
+ * for the session's lifetime, and renders `InkReplConsole`.
19
+ */
20
+ export function InkReplMode(props) {
21
+ const { devicePath, recover = false, logLevel, driver, watch } = props;
22
+ const handleEnd = useCallback(() => {
23
+ process.stdout.write('\x1b[<u');
24
+ process.exit(0);
25
+ }, []);
26
+ const deployEnabled = Boolean(driver);
27
+ const connection$ = useMemo(() => openSerial(devicePath, BAUD_RATE).pipe(
28
+ // Session is created BEFORE triggerSafeMode so the eager
29
+ // subscription inside connectRepl is listening when the
30
+ // post-reset MSG_READY arrives.
31
+ switchMap((serial) => {
32
+ const session = connectRepl(createSerialTransport(serial));
33
+ return recover ? from(triggerSafeMode(serial)).pipe(map(() => session)) : of(session);
34
+ }), map((session) => {
35
+ const repl = createRepl({
36
+ session,
37
+ port: devicePath,
38
+ onEnd: handleEnd,
39
+ deployEnabled,
40
+ });
41
+ return { session, repl };
42
+ }), catchError((err) => of(err instanceof Error ? err : new Error(String(err)))),
43
+ // refCount: false — the inner `switchMap` opens the serial and
44
+ // calls `triggerSafeMode`, which must happen exactly once per
45
+ // InkReplMode instance. With refCount: true, transient zero-
46
+ // subscriber windows would re-run the chain on next subscribe
47
+ // and reopen the port.
48
+ shareReplay({ bufferSize: 1, refCount: false })), [devicePath, recover, handleEnd, deployEnabled]);
49
+ const connection = useObservable(connection$, null);
50
+ const ready = connection && !(connection instanceof Error) ? connection : null;
51
+ // Keep `driver` in a ref so the effect below only re-runs when a new
52
+ // session is actually available. Caller memoisation would also work,
53
+ // but this puts the "run driver exactly once per session" contract
54
+ // in InkReplMode rather than relying on convention.
55
+ const driverRef = useRef(driver);
56
+ useEffect(() => {
57
+ driverRef.current = driver;
58
+ });
59
+ // Run the per-command driver while the session is alive.
60
+ useEffect(() => {
61
+ if (!ready)
62
+ return;
63
+ const spawned = driverRef.current?.({
64
+ session: ready.session,
65
+ repl: ready.repl,
66
+ devicePath,
67
+ });
68
+ if (!spawned)
69
+ return;
70
+ const sub = spawned.run$?.subscribe();
71
+ return () => {
72
+ sub?.unsubscribe();
73
+ spawned.dispose?.();
74
+ };
75
+ }, [ready, devicePath]);
76
+ // Ctrl+C / Ctrl+Q while still connecting — the REPL's own bindings
77
+ // take over once it's active.
78
+ useInput((_ch, key) => {
79
+ if (key.ctrl && (_ch === 'c' || _ch === 'q'))
80
+ process.exit(0);
81
+ }, { isActive: !ready });
82
+ if (connection instanceof Error) {
83
+ return _jsxs(Text, { color: "red", children: ["Connection error: ", connection.message] });
84
+ }
85
+ if (!ready) {
86
+ return (_jsxs(Text, { children: [_jsx(Spinner, { spinner: spinners.dots }), " Connecting to ", devicePath, "\u2026"] }));
87
+ }
88
+ return (_jsx(InkReplConsole, { session: ready.session, devicePath: devicePath, logLevel: logLevel, repl: ready.repl, watch: watch }));
89
+ }
90
+ //# sourceMappingURL=InkReplMode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkReplMode.js","sourceRoot":"","sources":["../../../../src/cli/lib/serial/InkReplMode.tsx"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,cAAc,CAAA;AACnC,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAC,MAAM,KAAK,CAAA;AAClC,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAA;AAC7D,OAAO,EAAC,UAAU,EAAE,IAAI,EAAE,GAAG,EAAmB,EAAE,EAAE,WAAW,EAAE,SAAS,EAAC,MAAM,MAAM,CAAA;AAGvF,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAA;AACtC,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAC,WAAW,EAAmB,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe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AI,EAAE,SAAS,EAAE,CAAA;QACrC,OAAO,GAAG,EAAE;YACV,GAAG,EAAE,WAAW,EAAE,CAAA;YAClB,OAAO,CAAC,OAAO,EAAE,EAAE,CAAA;QACrB,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAA;IAEvB,mEAAmE;IACnE,8BAA8B;IAC9B,QAAQ,CACN,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACX,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC/D,CAAC,EACD,EAAC,QAAQ,EAAE,CAAC,KAAK,EAAC,CACnB,CAAA;IAED,IAAI,UAAU,YAAY,KAAK,EAAE,CAAC;QAChC,OAAO,MAAC,IAAI,IAAC,KAAK,EAAC,KAAK,mCAAoB,UAAU,CAAC,OAAO,IAAQ,CAAA;IACxE,CAAC;IACD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CACL,MAAC,IAAI,eACH,KAAC,OAAO,IAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,GAAI,qBAAgB,UAAU,cACxD,CACR,CAAA;IACH,CAAC;IACD,OAAO,CACL,KAAC,cAAc,IACb,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,KAAK,EAAE,KAAK,GACZ,CACH,CAAA;AACH,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { LogLevel } from '../../../_exports/index.js';
2
+ import { type EnvEditorConfig } from '../../components/EnvEditor.js';
3
+ import { type ReplHandle } from './replStateMachine.js';
4
+ export interface ReplConsoleProps {
5
+ repl: ReplHandle;
6
+ config?: EnvEditorConfig;
7
+ /** Drop device-originated log events below this threshold. Host-side
8
+ * backstop for the build-time DCE, which can leak `console.debug`
9
+ * calls in arrow-callback positions. Defaults to `debug` (show all). */
10
+ logLevel?: LogLevel;
11
+ /** Adds a watch-mode line to the footer above the prompt. The footer
12
+ * also hosts progress messages (connecting, building, deploying,
13
+ * checking hooks); when nothing is in progress, the watch copy is
14
+ * shown. `true` → "Watching for file changes…", `false` → "File
15
+ * watching off. Press Ctrl+S to redeploy", `undefined` → the footer
16
+ * only appears while something is in progress (e.g. `mikro console`,
17
+ * where watching doesn't apply). */
18
+ watch?: boolean;
19
+ }
20
+ export declare function ReplConsole({ repl, config, logLevel, watch }: ReplConsoleProps): import("react/jsx-runtime").JSX.Element;
21
+ //# sourceMappingURL=ReplConsole.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReplConsole.d.ts","sourceRoot":"","sources":["../../../../src/cli/lib/serial/ReplConsole.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAY,KAAK,eAAe,EAAC,MAAM,+BAA+B,CAAA;AAK7E,OAAO,EAGL,KAAK,UAAU,EAGhB,MAAM,uBAAuB,CAAA;AAE9B,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,CAAC,EAAE,eAAe,CAAA;IACxB;;6EAEyE;IACzE,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB;;;;;;yCAMqC;IACrC,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAkLD,wBAAgB,WAAW,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,QAAkB,EAAE,KAAK,EAAC,EAAE,gBAAgB,2CAoMtF"}