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.
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/bin/mikrojs.js +3 -0
- package/dist/_exports/ble.d.ts +3 -0
- package/dist/_exports/ble.d.ts.map +1 -0
- package/dist/_exports/ble.js +2 -0
- package/dist/_exports/ble.js.map +1 -0
- package/dist/_exports/cbor.d.ts +3 -0
- package/dist/_exports/cbor.d.ts.map +1 -0
- package/dist/_exports/cbor.js +2 -0
- package/dist/_exports/cbor.js.map +1 -0
- package/dist/_exports/console.d.ts +2 -0
- package/dist/_exports/console.d.ts.map +1 -0
- package/dist/_exports/console.js +2 -0
- package/dist/_exports/console.js.map +1 -0
- package/dist/_exports/env.d.ts +2 -0
- package/dist/_exports/env.d.ts.map +1 -0
- package/dist/_exports/env.js +2 -0
- package/dist/_exports/env.js.map +1 -0
- package/dist/_exports/format.d.ts +2 -0
- package/dist/_exports/format.d.ts.map +1 -0
- package/dist/_exports/format.js +2 -0
- package/dist/_exports/format.js.map +1 -0
- package/dist/_exports/fs.d.ts +2 -0
- package/dist/_exports/fs.d.ts.map +1 -0
- package/dist/_exports/fs.js +2 -0
- package/dist/_exports/fs.js.map +1 -0
- package/dist/_exports/http/helpers.d.ts +3 -0
- package/dist/_exports/http/helpers.d.ts.map +1 -0
- package/dist/_exports/http/helpers.js +5 -0
- package/dist/_exports/http/helpers.js.map +1 -0
- package/dist/_exports/http/request.d.ts +4 -0
- package/dist/_exports/http/request.d.ts.map +1 -0
- package/dist/_exports/http/request.js +10 -0
- package/dist/_exports/http/request.js.map +1 -0
- package/dist/_exports/i2c.d.ts +2 -0
- package/dist/_exports/i2c.d.ts.map +1 -0
- package/dist/_exports/i2c.js +2 -0
- package/dist/_exports/i2c.js.map +1 -0
- package/dist/_exports/index.d.ts +61 -0
- package/dist/_exports/index.d.ts.map +1 -0
- package/dist/_exports/index.js +4 -0
- package/dist/_exports/index.js.map +1 -0
- package/dist/_exports/inspect.d.ts +2 -0
- package/dist/_exports/inspect.d.ts.map +1 -0
- package/dist/_exports/inspect.js +2 -0
- package/dist/_exports/inspect.js.map +1 -0
- package/dist/_exports/kv/nvs.d.ts +3 -0
- package/dist/_exports/kv/nvs.d.ts.map +1 -0
- package/dist/_exports/kv/nvs.js +2 -0
- package/dist/_exports/kv/nvs.js.map +1 -0
- package/dist/_exports/kv/rtc.d.ts +3 -0
- package/dist/_exports/kv/rtc.d.ts.map +1 -0
- package/dist/_exports/kv/rtc.js +2 -0
- package/dist/_exports/kv/rtc.js.map +1 -0
- package/dist/_exports/neopixel.d.ts +2 -0
- package/dist/_exports/neopixel.d.ts.map +1 -0
- package/dist/_exports/neopixel.js +2 -0
- package/dist/_exports/neopixel.js.map +1 -0
- package/dist/_exports/pin.d.ts +2 -0
- package/dist/_exports/pin.d.ts.map +1 -0
- package/dist/_exports/pin.js +2 -0
- package/dist/_exports/pin.js.map +1 -0
- package/dist/_exports/pwm.d.ts +2 -0
- package/dist/_exports/pwm.d.ts.map +1 -0
- package/dist/_exports/pwm.js +2 -0
- package/dist/_exports/pwm.js.map +1 -0
- package/dist/_exports/reader.d.ts +2 -0
- package/dist/_exports/reader.d.ts.map +1 -0
- package/dist/_exports/reader.js +2 -0
- package/dist/_exports/reader.js.map +1 -0
- package/dist/_exports/result.d.ts +2 -0
- package/dist/_exports/result.d.ts.map +1 -0
- package/dist/_exports/result.js +2 -0
- package/dist/_exports/result.js.map +1 -0
- package/dist/_exports/schema.d.ts +2 -0
- package/dist/_exports/schema.d.ts.map +1 -0
- package/dist/_exports/schema.js +2 -0
- package/dist/_exports/schema.js.map +1 -0
- package/dist/_exports/sim.d.ts +199 -0
- package/dist/_exports/sim.d.ts.map +1 -0
- package/dist/_exports/sim.js +8 -0
- package/dist/_exports/sim.js.map +1 -0
- package/dist/_exports/sleep.d.ts +2 -0
- package/dist/_exports/sleep.d.ts.map +1 -0
- package/dist/_exports/sleep.js +2 -0
- package/dist/_exports/sleep.js.map +1 -0
- package/dist/_exports/sntp.d.ts +3 -0
- package/dist/_exports/sntp.d.ts.map +1 -0
- package/dist/_exports/sntp.js +2 -0
- package/dist/_exports/sntp.js.map +1 -0
- package/dist/_exports/spi.d.ts +2 -0
- package/dist/_exports/spi.d.ts.map +1 -0
- package/dist/_exports/spi.js +2 -0
- package/dist/_exports/spi.js.map +1 -0
- package/dist/_exports/stdio.d.ts +2 -0
- package/dist/_exports/stdio.d.ts.map +1 -0
- package/dist/_exports/stdio.js +2 -0
- package/dist/_exports/stdio.js.map +1 -0
- package/dist/_exports/stream.d.ts +2 -0
- package/dist/_exports/stream.d.ts.map +1 -0
- package/dist/_exports/stream.js +2 -0
- package/dist/_exports/stream.js.map +1 -0
- package/dist/_exports/sys.d.ts +2 -0
- package/dist/_exports/sys.d.ts.map +1 -0
- package/dist/_exports/sys.js +2 -0
- package/dist/_exports/sys.js.map +1 -0
- package/dist/_exports/test.d.ts +2 -0
- package/dist/_exports/test.d.ts.map +1 -0
- package/dist/_exports/test.js +2 -0
- package/dist/_exports/test.js.map +1 -0
- package/dist/_exports/uart.d.ts +2 -0
- package/dist/_exports/uart.d.ts.map +1 -0
- package/dist/_exports/uart.js +2 -0
- package/dist/_exports/uart.js.map +1 -0
- package/dist/_exports/wifi.d.ts +3 -0
- package/dist/_exports/wifi.d.ts.map +1 -0
- package/dist/_exports/wifi.js +2 -0
- package/dist/_exports/wifi.js.map +1 -0
- package/dist/cli/cli.d.ts +3 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/cli/cli.js +215 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/cliWrapper.d.ts +3 -0
- package/dist/cli/cliWrapper.d.ts.map +1 -0
- package/dist/cli/cliWrapper.js +40 -0
- package/dist/cli/cliWrapper.js.map +1 -0
- package/dist/cli/commands/build-runtime.d.ts +14 -0
- package/dist/cli/commands/build-runtime.d.ts.map +1 -0
- package/dist/cli/commands/build-runtime.js +122 -0
- package/dist/cli/commands/build-runtime.js.map +1 -0
- package/dist/cli/commands/build.d.ts +31 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +145 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/clean.d.ts +16 -0
- package/dist/cli/commands/clean.d.ts.map +1 -0
- package/dist/cli/commands/clean.js +148 -0
- package/dist/cli/commands/clean.js.map +1 -0
- package/dist/cli/commands/console.d.ts +19 -0
- package/dist/cli/commands/console.d.ts.map +1 -0
- package/dist/cli/commands/console.js +32 -0
- package/dist/cli/commands/console.js.map +1 -0
- package/dist/cli/commands/deploy.d.ts +63 -0
- package/dist/cli/commands/deploy.d.ts.map +1 -0
- package/dist/cli/commands/deploy.js +242 -0
- package/dist/cli/commands/deploy.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +41 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +170 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/docs.d.ts +7 -0
- package/dist/cli/commands/docs.d.ts.map +1 -0
- package/dist/cli/commands/docs.js +20 -0
- package/dist/cli/commands/docs.js.map +1 -0
- package/dist/cli/commands/env.d.ts +59 -0
- package/dist/cli/commands/env.d.ts.map +1 -0
- package/dist/cli/commands/env.js +257 -0
- package/dist/cli/commands/env.js.map +1 -0
- package/dist/cli/commands/erase.d.ts +18 -0
- package/dist/cli/commands/erase.d.ts.map +1 -0
- package/dist/cli/commands/erase.js +90 -0
- package/dist/cli/commands/erase.js.map +1 -0
- package/dist/cli/commands/flash.d.ts +30 -0
- package/dist/cli/commands/flash.d.ts.map +1 -0
- package/dist/cli/commands/flash.js +243 -0
- package/dist/cli/commands/flash.js.map +1 -0
- package/dist/cli/commands/home.d.ts +7 -0
- package/dist/cli/commands/home.d.ts.map +1 -0
- package/dist/cli/commands/home.js +20 -0
- package/dist/cli/commands/home.js.map +1 -0
- package/dist/cli/commands/ls.d.ts +17 -0
- package/dist/cli/commands/ls.d.ts.map +1 -0
- package/dist/cli/commands/ls.js +62 -0
- package/dist/cli/commands/ls.js.map +1 -0
- package/dist/cli/commands/sim/clean.d.ts +7 -0
- package/dist/cli/commands/sim/clean.d.ts.map +1 -0
- package/dist/cli/commands/sim/clean.js +34 -0
- package/dist/cli/commands/sim/clean.js.map +1 -0
- package/dist/cli/commands/sim/deploy.d.ts +46 -0
- package/dist/cli/commands/sim/deploy.d.ts.map +1 -0
- package/dist/cli/commands/sim/deploy.js +127 -0
- package/dist/cli/commands/sim/deploy.js.map +1 -0
- package/dist/cli/commands/sim/dev.d.ts +52 -0
- package/dist/cli/commands/sim/dev.d.ts.map +1 -0
- package/dist/cli/commands/sim/dev.js +380 -0
- package/dist/cli/commands/sim/dev.js.map +1 -0
- package/dist/cli/commands/sim/env.d.ts +56 -0
- package/dist/cli/commands/sim/env.d.ts.map +1 -0
- package/dist/cli/commands/sim/env.js +204 -0
- package/dist/cli/commands/sim/env.js.map +1 -0
- package/dist/cli/commands/sim/profile.d.ts +67 -0
- package/dist/cli/commands/sim/profile.d.ts.map +1 -0
- package/dist/cli/commands/sim/profile.js +356 -0
- package/dist/cli/commands/sim/profile.js.map +1 -0
- package/dist/cli/commands/sim/repl.d.ts +16 -0
- package/dist/cli/commands/sim/repl.d.ts.map +1 -0
- package/dist/cli/commands/sim/repl.js +119 -0
- package/dist/cli/commands/sim/repl.js.map +1 -0
- package/dist/cli/commands/sim/reset.d.ts +11 -0
- package/dist/cli/commands/sim/reset.d.ts.map +1 -0
- package/dist/cli/commands/sim/reset.js +59 -0
- package/dist/cli/commands/sim/reset.js.map +1 -0
- package/dist/cli/commands/sim/scaffold.d.ts +11 -0
- package/dist/cli/commands/sim/scaffold.d.ts.map +1 -0
- package/dist/cli/commands/sim/scaffold.js +41 -0
- package/dist/cli/commands/sim/scaffold.js.map +1 -0
- package/dist/cli/commands/sim/test.d.ts +49 -0
- package/dist/cli/commands/sim/test.d.ts.map +1 -0
- package/dist/cli/commands/sim/test.js +364 -0
- package/dist/cli/commands/sim/test.js.map +1 -0
- package/dist/cli/commands/sim.d.ts +228 -0
- package/dist/cli/commands/sim.d.ts.map +1 -0
- package/dist/cli/commands/sim.js +69 -0
- package/dist/cli/commands/sim.js.map +1 -0
- package/dist/cli/commands/tail.d.ts +14 -0
- package/dist/cli/commands/tail.d.ts.map +1 -0
- package/dist/cli/commands/tail.js +50 -0
- package/dist/cli/commands/tail.js.map +1 -0
- package/dist/cli/commands/test.d.ts +39 -0
- package/dist/cli/commands/test.d.ts.map +1 -0
- package/dist/cli/commands/test.js +432 -0
- package/dist/cli/commands/test.js.map +1 -0
- package/dist/cli/components/DevicePicker.d.ts +9 -0
- package/dist/cli/components/DevicePicker.d.ts.map +1 -0
- package/dist/cli/components/DevicePicker.js +71 -0
- package/dist/cli/components/DevicePicker.js.map +1 -0
- package/dist/cli/components/EnvEditor.d.ts +12 -0
- package/dist/cli/components/EnvEditor.d.ts.map +1 -0
- package/dist/cli/components/EnvEditor.js +201 -0
- package/dist/cli/components/EnvEditor.js.map +1 -0
- package/dist/cli/components/TextInput.d.ts +28 -0
- package/dist/cli/components/TextInput.d.ts.map +1 -0
- package/dist/cli/components/TextInput.js +73 -0
- package/dist/cli/components/TextInput.js.map +1 -0
- package/dist/cli/components/TitledBox.d.ts +27 -0
- package/dist/cli/components/TitledBox.d.ts.map +1 -0
- package/dist/cli/components/TitledBox.js +111 -0
- package/dist/cli/components/TitledBox.js.map +1 -0
- package/dist/cli/hooks/useDevices.d.ts +23 -0
- package/dist/cli/hooks/useDevices.d.ts.map +1 -0
- package/dist/cli/hooks/useDevices.js +19 -0
- package/dist/cli/hooks/useDevices.js.map +1 -0
- package/dist/cli/lib/RenderAndExit.d.ts +6 -0
- package/dist/cli/lib/RenderAndExit.d.ts.map +1 -0
- package/dist/cli/lib/RenderAndExit.js +8 -0
- package/dist/cli/lib/RenderAndExit.js.map +1 -0
- package/dist/cli/lib/Spinner.d.ts +11 -0
- package/dist/cli/lib/Spinner.d.ts.map +1 -0
- package/dist/cli/lib/Spinner.js +22 -0
- package/dist/cli/lib/Spinner.js.map +1 -0
- package/dist/cli/lib/agent.d.ts +38 -0
- package/dist/cli/lib/agent.d.ts.map +1 -0
- package/dist/cli/lib/agent.js +87 -0
- package/dist/cli/lib/agent.js.map +1 -0
- package/dist/cli/lib/boards.d.ts +23 -0
- package/dist/cli/lib/boards.d.ts.map +1 -0
- package/dist/cli/lib/boards.js +67 -0
- package/dist/cli/lib/boards.js.map +1 -0
- package/dist/cli/lib/build.d.ts +47 -0
- package/dist/cli/lib/build.d.ts.map +1 -0
- package/dist/cli/lib/build.js +533 -0
- package/dist/cli/lib/build.js.map +1 -0
- package/dist/cli/lib/connectSim.d.ts +21 -0
- package/dist/cli/lib/connectSim.d.ts.map +1 -0
- package/dist/cli/lib/connectSim.js +20 -0
- package/dist/cli/lib/connectSim.js.map +1 -0
- package/dist/cli/lib/deploy.d.ts +42 -0
- package/dist/cli/lib/deploy.d.ts.map +1 -0
- package/dist/cli/lib/deploy.js +121 -0
- package/dist/cli/lib/deploy.js.map +1 -0
- package/dist/cli/lib/deployProgress.d.ts +8 -0
- package/dist/cli/lib/deployProgress.d.ts.map +1 -0
- package/dist/cli/lib/deployProgress.js +32 -0
- package/dist/cli/lib/deployProgress.js.map +1 -0
- package/dist/cli/lib/dotenv.d.ts +16 -0
- package/dist/cli/lib/dotenv.d.ts.map +1 -0
- package/dist/cli/lib/dotenv.js +33 -0
- package/dist/cli/lib/dotenv.js.map +1 -0
- package/dist/cli/lib/esbuild.d.ts +7 -0
- package/dist/cli/lib/esbuild.d.ts.map +1 -0
- package/dist/cli/lib/esbuild.js +15 -0
- package/dist/cli/lib/esbuild.js.map +1 -0
- package/dist/cli/lib/esptool.d.ts +41 -0
- package/dist/cli/lib/esptool.d.ts.map +1 -0
- package/dist/cli/lib/esptool.js +43 -0
- package/dist/cli/lib/esptool.js.map +1 -0
- package/dist/cli/lib/firmware.d.ts +24 -0
- package/dist/cli/lib/firmware.d.ts.map +1 -0
- package/dist/cli/lib/firmware.js +406 -0
- package/dist/cli/lib/firmware.js.map +1 -0
- package/dist/cli/lib/firmwareCompat.d.ts +19 -0
- package/dist/cli/lib/firmwareCompat.d.ts.map +1 -0
- package/dist/cli/lib/firmwareCompat.js +31 -0
- package/dist/cli/lib/firmwareCompat.js.map +1 -0
- package/dist/cli/lib/heapBaseline.d.ts +15 -0
- package/dist/cli/lib/heapBaseline.d.ts.map +1 -0
- package/dist/cli/lib/heapBaseline.js +39 -0
- package/dist/cli/lib/heapBaseline.js.map +1 -0
- package/dist/cli/lib/ink-table/index.d.ts +88 -0
- package/dist/cli/lib/ink-table/index.d.ts.map +1 -0
- package/dist/cli/lib/ink-table/index.js +217 -0
- package/dist/cli/lib/ink-table/index.js.map +1 -0
- package/dist/cli/lib/loadMikroConfig.d.ts +7 -0
- package/dist/cli/lib/loadMikroConfig.d.ts.map +1 -0
- package/dist/cli/lib/loadMikroConfig.js +26 -0
- package/dist/cli/lib/loadMikroConfig.js.map +1 -0
- package/dist/cli/lib/minify.d.ts +3 -0
- package/dist/cli/lib/minify.d.ts.map +1 -0
- package/dist/cli/lib/minify.js +89 -0
- package/dist/cli/lib/minify.js.map +1 -0
- package/dist/cli/lib/openSim.d.ts +29 -0
- package/dist/cli/lib/openSim.d.ts.map +1 -0
- package/dist/cli/lib/openSim.js +32 -0
- package/dist/cli/lib/openSim.js.map +1 -0
- package/dist/cli/lib/ospawn.d.ts +34 -0
- package/dist/cli/lib/ospawn.d.ts.map +1 -0
- package/dist/cli/lib/ospawn.js +90 -0
- package/dist/cli/lib/ospawn.js.map +1 -0
- package/dist/cli/lib/parseMinifier.d.ts +10 -0
- package/dist/cli/lib/parseMinifier.d.ts.map +1 -0
- package/dist/cli/lib/parseMinifier.js +49 -0
- package/dist/cli/lib/parseMinifier.js.map +1 -0
- package/dist/cli/lib/parseSize.d.ts +6 -0
- package/dist/cli/lib/parseSize.d.ts.map +1 -0
- package/dist/cli/lib/parseSize.js +25 -0
- package/dist/cli/lib/parseSize.js.map +1 -0
- package/dist/cli/lib/projectRoot.d.ts +11 -0
- package/dist/cli/lib/projectRoot.d.ts.map +1 -0
- package/dist/cli/lib/projectRoot.js +28 -0
- package/dist/cli/lib/projectRoot.js.map +1 -0
- package/dist/cli/lib/protocol.d.ts +144 -0
- package/dist/cli/lib/protocol.d.ts.map +1 -0
- package/dist/cli/lib/protocol.js +385 -0
- package/dist/cli/lib/protocol.js.map +1 -0
- package/dist/cli/lib/recover.d.ts +25 -0
- package/dist/cli/lib/recover.d.ts.map +1 -0
- package/dist/cli/lib/recover.js +144 -0
- package/dist/cli/lib/recover.js.map +1 -0
- package/dist/cli/lib/resolveEntry.d.ts +7 -0
- package/dist/cli/lib/resolveEntry.d.ts.map +1 -0
- package/dist/cli/lib/resolveEntry.js +30 -0
- package/dist/cli/lib/resolveEntry.js.map +1 -0
- package/dist/cli/lib/runHooks.d.ts +34 -0
- package/dist/cli/lib/runHooks.d.ts.map +1 -0
- package/dist/cli/lib/runHooks.js +90 -0
- package/dist/cli/lib/runHooks.js.map +1 -0
- package/dist/cli/lib/serial/InkReplConsole.d.ts +27 -0
- package/dist/cli/lib/serial/InkReplConsole.d.ts.map +1 -0
- package/dist/cli/lib/serial/InkReplConsole.js +24 -0
- package/dist/cli/lib/serial/InkReplConsole.js.map +1 -0
- package/dist/cli/lib/serial/InkReplMode.d.ts +38 -0
- package/dist/cli/lib/serial/InkReplMode.d.ts.map +1 -0
- package/dist/cli/lib/serial/InkReplMode.js +90 -0
- package/dist/cli/lib/serial/InkReplMode.js.map +1 -0
- package/dist/cli/lib/serial/ReplConsole.d.ts +21 -0
- package/dist/cli/lib/serial/ReplConsole.d.ts.map +1 -0
- package/dist/cli/lib/serial/ReplConsole.js +249 -0
- package/dist/cli/lib/serial/ReplConsole.js.map +1 -0
- package/dist/cli/lib/serial/devSession.d.ts +57 -0
- package/dist/cli/lib/serial/devSession.d.ts.map +1 -0
- package/dist/cli/lib/serial/devSession.js +160 -0
- package/dist/cli/lib/serial/devSession.js.map +1 -0
- package/dist/cli/lib/serial/dispatchReplCommand.d.ts +25 -0
- package/dist/cli/lib/serial/dispatchReplCommand.d.ts.map +1 -0
- package/dist/cli/lib/serial/dispatchReplCommand.js +27 -0
- package/dist/cli/lib/serial/dispatchReplCommand.js.map +1 -0
- package/dist/cli/lib/serial/openSession.d.ts +28 -0
- package/dist/cli/lib/serial/openSession.d.ts.map +1 -0
- package/dist/cli/lib/serial/openSession.js +48 -0
- package/dist/cli/lib/serial/openSession.js.map +1 -0
- package/dist/cli/lib/serial/replStateMachine.d.ts +169 -0
- package/dist/cli/lib/serial/replStateMachine.d.ts.map +1 -0
- package/dist/cli/lib/serial/replStateMachine.js +657 -0
- package/dist/cli/lib/serial/replStateMachine.js.map +1 -0
- package/dist/cli/lib/serial/runAgentRepl.d.ts +33 -0
- package/dist/cli/lib/serial/runAgentRepl.d.ts.map +1 -0
- package/dist/cli/lib/serial/runAgentRepl.js +80 -0
- package/dist/cli/lib/serial/runAgentRepl.js.map +1 -0
- package/dist/cli/lib/session.d.ts +163 -0
- package/dist/cli/lib/session.d.ts.map +1 -0
- package/dist/cli/lib/session.js +490 -0
- package/dist/cli/lib/session.js.map +1 -0
- package/dist/cli/lib/simConfig.d.ts +15 -0
- package/dist/cli/lib/simConfig.d.ts.map +1 -0
- package/dist/cli/lib/simConfig.js +25 -0
- package/dist/cli/lib/simConfig.js.map +1 -0
- package/dist/cli/lib/simPid.d.ts +30 -0
- package/dist/cli/lib/simPid.d.ts.map +1 -0
- package/dist/cli/lib/simPid.js +120 -0
- package/dist/cli/lib/simPid.js.map +1 -0
- package/dist/cli/lib/simTransport.d.ts +17 -0
- package/dist/cli/lib/simTransport.d.ts.map +1 -0
- package/dist/cli/lib/simTransport.js +80 -0
- package/dist/cli/lib/simTransport.js.map +1 -0
- package/dist/cli/lib/testRunner.d.ts +86 -0
- package/dist/cli/lib/testRunner.d.ts.map +1 -0
- package/dist/cli/lib/testRunner.js +469 -0
- package/dist/cli/lib/testRunner.js.map +1 -0
- package/dist/cli/lib/transport.d.ts +34 -0
- package/dist/cli/lib/transport.d.ts.map +1 -0
- package/dist/cli/lib/transport.js +117 -0
- package/dist/cli/lib/transport.js.map +1 -0
- package/dist/cli/lib/useObservable.d.ts +4 -0
- package/dist/cli/lib/useObservable.d.ts.map +1 -0
- package/dist/cli/lib/useObservable.js +22 -0
- package/dist/cli/lib/useObservable.js.map +1 -0
- package/dist/cli/lib/watcher.d.ts +10 -0
- package/dist/cli/lib/watcher.d.ts.map +1 -0
- package/dist/cli/lib/watcher.js +34 -0
- package/dist/cli/lib/watcher.js.map +1 -0
- package/dist/constants.d.ts +13 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +27 -0
- package/dist/constants.js.map +1 -0
- package/dist/simulator/builtins/ble.d.ts +3 -0
- package/dist/simulator/builtins/ble.d.ts.map +1 -0
- package/dist/simulator/builtins/ble.js +46 -0
- package/dist/simulator/builtins/ble.js.map +1 -0
- package/dist/simulator/builtins/console.d.ts +8 -0
- package/dist/simulator/builtins/console.d.ts.map +1 -0
- package/dist/simulator/builtins/console.js +24 -0
- package/dist/simulator/builtins/console.js.map +1 -0
- package/dist/simulator/builtins/http.d.ts +3 -0
- package/dist/simulator/builtins/http.d.ts.map +1 -0
- package/dist/simulator/builtins/http.js +90 -0
- package/dist/simulator/builtins/http.js.map +1 -0
- package/dist/simulator/builtins/i2c.d.ts +3 -0
- package/dist/simulator/builtins/i2c.d.ts.map +1 -0
- package/dist/simulator/builtins/i2c.js +17 -0
- package/dist/simulator/builtins/i2c.js.map +1 -0
- package/dist/simulator/builtins/index.d.ts +7 -0
- package/dist/simulator/builtins/index.d.ts.map +1 -0
- package/dist/simulator/builtins/index.js +49 -0
- package/dist/simulator/builtins/index.js.map +1 -0
- package/dist/simulator/builtins/kv.d.ts +3 -0
- package/dist/simulator/builtins/kv.d.ts.map +1 -0
- package/dist/simulator/builtins/kv.js +39 -0
- package/dist/simulator/builtins/kv.js.map +1 -0
- package/dist/simulator/builtins/neopixel.d.ts +3 -0
- package/dist/simulator/builtins/neopixel.d.ts.map +1 -0
- package/dist/simulator/builtins/neopixel.js +15 -0
- package/dist/simulator/builtins/neopixel.js.map +1 -0
- package/dist/simulator/builtins/nvs-kv.d.ts +3 -0
- package/dist/simulator/builtins/nvs-kv.d.ts.map +1 -0
- package/dist/simulator/builtins/nvs-kv.js +69 -0
- package/dist/simulator/builtins/nvs-kv.js.map +1 -0
- package/dist/simulator/builtins/pin.d.ts +3 -0
- package/dist/simulator/builtins/pin.d.ts.map +1 -0
- package/dist/simulator/builtins/pin.js +32 -0
- package/dist/simulator/builtins/pin.js.map +1 -0
- package/dist/simulator/builtins/pwm.d.ts +3 -0
- package/dist/simulator/builtins/pwm.d.ts.map +1 -0
- package/dist/simulator/builtins/pwm.js +31 -0
- package/dist/simulator/builtins/pwm.js.map +1 -0
- package/dist/simulator/builtins/sleep.d.ts +3 -0
- package/dist/simulator/builtins/sleep.d.ts.map +1 -0
- package/dist/simulator/builtins/sleep.js +33 -0
- package/dist/simulator/builtins/sleep.js.map +1 -0
- package/dist/simulator/builtins/sntp.d.ts +3 -0
- package/dist/simulator/builtins/sntp.d.ts.map +1 -0
- package/dist/simulator/builtins/sntp.js +14 -0
- package/dist/simulator/builtins/sntp.js.map +1 -0
- package/dist/simulator/builtins/spi.d.ts +3 -0
- package/dist/simulator/builtins/spi.d.ts.map +1 -0
- package/dist/simulator/builtins/spi.js +16 -0
- package/dist/simulator/builtins/spi.js.map +1 -0
- package/dist/simulator/builtins/types.d.ts +24 -0
- package/dist/simulator/builtins/types.d.ts.map +1 -0
- package/dist/simulator/builtins/types.js +2 -0
- package/dist/simulator/builtins/types.js.map +1 -0
- package/dist/simulator/builtins/uart.d.ts +3 -0
- package/dist/simulator/builtins/uart.d.ts.map +1 -0
- package/dist/simulator/builtins/uart.js +22 -0
- package/dist/simulator/builtins/uart.js.map +1 -0
- package/dist/simulator/builtins/wifi.d.ts +3 -0
- package/dist/simulator/builtins/wifi.d.ts.map +1 -0
- package/dist/simulator/builtins/wifi.js +55 -0
- package/dist/simulator/builtins/wifi.js.map +1 -0
- package/dist/simulator/devRunner.d.ts +41 -0
- package/dist/simulator/devRunner.d.ts.map +1 -0
- package/dist/simulator/devRunner.js +201 -0
- package/dist/simulator/devRunner.js.map +1 -0
- package/dist/simulator/loadSimStubs.d.ts +15 -0
- package/dist/simulator/loadSimStubs.d.ts.map +1 -0
- package/dist/simulator/loadSimStubs.js +54 -0
- package/dist/simulator/loadSimStubs.js.map +1 -0
- package/dist/simulator/simProcess.d.ts +11 -0
- package/dist/simulator/simProcess.d.ts.map +1 -0
- package/dist/simulator/simProcess.js +957 -0
- package/dist/simulator/simProcess.js.map +1 -0
- package/dist/simulator/simTemplates.d.ts +6 -0
- package/dist/simulator/simTemplates.d.ts.map +1 -0
- package/dist/simulator/simTemplates.js +21 -0
- package/dist/simulator/simTemplates.js.map +1 -0
- package/package.json +123 -2
- package/runtime.d.ts +95 -0
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReplSession — transport-agnostic protocol session.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* const session = connectRepl(transport)
|
|
6
|
+
* session.messages$.subscribe(event => ...)
|
|
7
|
+
* session.eval('1+1')
|
|
8
|
+
* await session.deploy(files, envVars)
|
|
9
|
+
* session.close()
|
|
10
|
+
*/
|
|
11
|
+
import { createHash } from 'node:crypto';
|
|
12
|
+
import { decode as decodeCbor } from 'cbor2';
|
|
13
|
+
import { catchError, concat, filter, finalize, first, firstValueFrom, from, ignoreElements, map, merge, mergeMap, of, share, shareReplay, switchMap, tap, timeout, timer, } from 'rxjs';
|
|
14
|
+
import { checkFirmwareCompat } from './firmwareCompat.js';
|
|
15
|
+
import { buildCompleteCommand, buildConfigDeleteCommand, buildConfigListCommand, buildConfigSetCommand, buildDeployAbortCommand, buildDeployChecksumCommand, buildDeployDoneCommand, buildDeployEraseCommand, buildDeployKeepCommand, buildDeployPutChunkCommand, buildDeployPutCommand, buildDirectiveCommand, buildEvalCommand, buildExitCommand, buildHelloCommand, buildRestartCommand, buildRuntimePauseCommand, buildRuntimeResumeCommand, FrameParser, frameToMessage, parseCompletions, } from './protocol.js';
|
|
16
|
+
function isResponseEvent(event) {
|
|
17
|
+
return (event.type === 'ok' ||
|
|
18
|
+
event.type === 'err' ||
|
|
19
|
+
event.type === 'checksum_result' ||
|
|
20
|
+
event.type === 'config_entries');
|
|
21
|
+
}
|
|
22
|
+
// ── Checksums manifest ─────────────────────────────────────────────
|
|
23
|
+
const CHECKSUMS_PATH = '/app/.checksums';
|
|
24
|
+
function buildChecksumsManifest(hashes) {
|
|
25
|
+
const lines = [];
|
|
26
|
+
for (const [name, hash] of hashes) {
|
|
27
|
+
lines.push(`${hash.toString('hex')} ${name}\n`);
|
|
28
|
+
}
|
|
29
|
+
return Buffer.from(lines.join(''));
|
|
30
|
+
}
|
|
31
|
+
// ── connectRepl ────────────────────────────────────────────────────
|
|
32
|
+
/** Window for MSG_READY after CMD_RESTART. A healthy reboot is <1s, but
|
|
33
|
+
* CMD_RESTART itself only gets serviced when the device's JS thread
|
|
34
|
+
* yields — and apps doing display/modem work can block it for several
|
|
35
|
+
* seconds. 10s accommodates both without hanging forever on a wedged
|
|
36
|
+
* device. Callers can override via `DeployOptions.timeout`. */
|
|
37
|
+
const READY_TIMEOUT_MS = 10_000;
|
|
38
|
+
const RESPONSE_TIMEOUT_MS = 30_000;
|
|
39
|
+
/** How often awaitReady$ re-sends CMD_HELLO while waiting for MSG_READY.
|
|
40
|
+
* The device replies immediately, so a single HELLO normally suffices.
|
|
41
|
+
* Polling exists to cover (a) the post-restart window where the transport
|
|
42
|
+
* is down or the device is mid-reboot and (b) connections established
|
|
43
|
+
* before the device's protocol mode is up. */
|
|
44
|
+
const HELLO_POLL_INTERVAL_MS = 250;
|
|
45
|
+
/** Timeout for protocol commands whose on-device work is near-instant
|
|
46
|
+
* (pause, resume) but whose handler is interleaved with JS. The budget
|
|
47
|
+
* isn't for the command itself — it's for the longest plausible
|
|
48
|
+
* blocking JS native call (display SPI, flash write, etc.) that can
|
|
49
|
+
* delay the next handler tick. */
|
|
50
|
+
const JS_YIELD_TIMEOUT_MS = 10_000;
|
|
51
|
+
/** Body bytes per CMD_DEPLOY_PUT_CHUNK frame. Sized so a single TLV frame
|
|
52
|
+
* (5-byte header + body) stays well below the device's USJ RX ring with
|
|
53
|
+
* room for the next command's header to land alongside it. Larger chunks
|
|
54
|
+
* trade per-chunk round-trip cost against the risk of overrun on devices
|
|
55
|
+
* with smaller rings — 2 KB is the sweet spot for both the ESP32 USJ peripheral
|
|
56
|
+
* (RX 4 KB) and any plausible UART path. */
|
|
57
|
+
const PUT_CHUNK_SIZE = 2048;
|
|
58
|
+
function formatTimeoutError(context, timeoutMs) {
|
|
59
|
+
return new Error(`${context}: device did not respond within ${timeoutMs}ms — it may be unplugged, wedged in a long JS operation, or (outside dev mode) in deep sleep`);
|
|
60
|
+
}
|
|
61
|
+
export function connectRepl(transport, _connectOptions = {}) {
|
|
62
|
+
const frameParser = new FrameParser();
|
|
63
|
+
let sub;
|
|
64
|
+
// Buffer for raw (non-protocol) bytes so we only emit complete lines.
|
|
65
|
+
let rawLineBuf = '';
|
|
66
|
+
// Core observable: transport bytes → parsed ReplEvents (shared/hot).
|
|
67
|
+
// Emits a 'disconnect' event when the transport completes, then completes.
|
|
68
|
+
const messages$ = concat(transport.data.pipe(mergeMap((chunk) => {
|
|
69
|
+
const { frames, raw } = frameParser.feed(Buffer.from(chunk));
|
|
70
|
+
const events = [];
|
|
71
|
+
if (raw) {
|
|
72
|
+
rawLineBuf += raw.toString('utf-8');
|
|
73
|
+
// Emit only complete lines; keep the trailing partial for later
|
|
74
|
+
const lastNewline = rawLineBuf.lastIndexOf('\n');
|
|
75
|
+
if (lastNewline !== -1) {
|
|
76
|
+
const complete = rawLineBuf.slice(0, lastNewline).trim();
|
|
77
|
+
rawLineBuf = rawLineBuf.slice(lastNewline + 1);
|
|
78
|
+
if (complete)
|
|
79
|
+
events.push({ type: 'raw', text: complete });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
for (const frame of frames) {
|
|
83
|
+
const event = frameToEvent(frame);
|
|
84
|
+
if (event)
|
|
85
|
+
events.push(event);
|
|
86
|
+
}
|
|
87
|
+
return events;
|
|
88
|
+
}), finalize(() => {
|
|
89
|
+
frameParser.flush();
|
|
90
|
+
rawLineBuf = '';
|
|
91
|
+
})), [{ type: 'disconnect' }]).pipe(share());
|
|
92
|
+
// Keep the pipeline alive (shared observables need at least one subscriber)
|
|
93
|
+
sub = messages$.subscribe();
|
|
94
|
+
// ready$: emits each time the device sends MSG_READY (after boot or restart).
|
|
95
|
+
// Tagged with a sequence number AND arrival timestamp so awaitReady$ can
|
|
96
|
+
// distinguish a genuinely post-restart ready from one that pre-dates the
|
|
97
|
+
// reboot. After `session.restart()`, two failure modes need filtering:
|
|
98
|
+
// 1. The previously-cached MSG_READY replayed by shareReplay (caught by
|
|
99
|
+
// sequence number — restart() snapshots the current seq).
|
|
100
|
+
// 2. A pre-restart MSG_READY that was already in the OS read buffer or
|
|
101
|
+
// otherwise in flight when restart() ran, so it arrives shortly
|
|
102
|
+
// *after* the seq snapshot but is still from the pre-reboot device
|
|
103
|
+
// state. The sequence check passes for these, but the timestamp
|
|
104
|
+
// doesn't: a real post-reboot MSG_READY arrives at least one boot
|
|
105
|
+
// cycle (~500 ms) later. We require a 1 s blackout to be safe.
|
|
106
|
+
// Both conditions together prevent deploy from sending CMD_RUNTIME_PAUSE
|
|
107
|
+
// while the device is still rebooting (which lands during the USB-CDC
|
|
108
|
+
// re-enumeration window and gets dropped).
|
|
109
|
+
let readySeq = 0;
|
|
110
|
+
let lastSeenRestartSeq = -1;
|
|
111
|
+
let lastRestartAt = 0;
|
|
112
|
+
const POST_RESTART_BLACKOUT_MS = 1000;
|
|
113
|
+
const readyWithMeta$ = messages$.pipe(filter((e) => e.type === 'ready'), map((e) => ({ event: e, seq: ++readySeq, arrivedAt: Date.now() })), shareReplay(1));
|
|
114
|
+
// Eagerly subscribe so shareReplay captures ready events
|
|
115
|
+
sub.add(readyWithMeta$.subscribe());
|
|
116
|
+
const ready$ = readyWithMeta$.pipe(map(({ event }) => event));
|
|
117
|
+
// Response stream: OK, ERR, CHECKSUM_RESULT, CONFIG_ENTRIES
|
|
118
|
+
const responses$ = messages$.pipe(filter(isResponseEvent));
|
|
119
|
+
/** Send a command and wait for the next response event. Wraps any
|
|
120
|
+
* timeout with a message naming the step, so a user seeing a
|
|
121
|
+
* generic rxjs TimeoutError gets context instead. */
|
|
122
|
+
async function sendAndWait(frame, context, timeoutMs = RESPONSE_TIMEOUT_MS) {
|
|
123
|
+
const response = firstValueFrom(responses$.pipe(first(), timeout(timeoutMs)));
|
|
124
|
+
await transport.write(frame);
|
|
125
|
+
try {
|
|
126
|
+
return await response;
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
if (err instanceof Error && err.name === 'TimeoutError') {
|
|
130
|
+
throw formatTimeoutError(context, timeoutMs);
|
|
131
|
+
}
|
|
132
|
+
throw err;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/** Send a command and expect MSG_OK. Throws on MSG_ERR or timeout.
|
|
136
|
+
* Returns the OK payload so callers can inspect extra bytes (e.g. the
|
|
137
|
+
* changed/existed flag returned by CONFIG_SET / CONFIG_DELETE). */
|
|
138
|
+
async function sendExpectOk(frame, context, timeoutMs) {
|
|
139
|
+
const resp = await sendAndWait(frame, context, timeoutMs);
|
|
140
|
+
if (resp.type === 'err') {
|
|
141
|
+
throw new Error(`${context}: ${resp.message}`);
|
|
142
|
+
}
|
|
143
|
+
if (resp.type !== 'ok') {
|
|
144
|
+
throw new Error(`${context}: unexpected response type '${resp.type}'`);
|
|
145
|
+
}
|
|
146
|
+
return resp.payload;
|
|
147
|
+
}
|
|
148
|
+
/** Stream a file to the device as one CMD_DEPLOY_PUT (begin) followed by
|
|
149
|
+
* one or more CMD_DEPLOY_PUT_CHUNK frames. Each frame awaits MSG_OK
|
|
150
|
+
* before the next is sent so the device's RX ring can never overrun
|
|
151
|
+
* regardless of file size. Empty files are valid: BEGIN with size=0
|
|
152
|
+
* closes the file immediately and no chunks are sent. */
|
|
153
|
+
async function streamPutFile(path, data) {
|
|
154
|
+
await sendExpectOk(buildDeployPutCommand(path, data.length), `deploy put '${path}'`);
|
|
155
|
+
for (let offset = 0; offset < data.length; offset += PUT_CHUNK_SIZE) {
|
|
156
|
+
const chunk = data.subarray(offset, offset + PUT_CHUNK_SIZE);
|
|
157
|
+
await sendExpectOk(buildDeployPutChunkCommand(chunk), `deploy put chunk '${path}' @${offset}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Wait for device to be ready. Emits the ReadyEvent, then completes.
|
|
162
|
+
* Errors if the device firmware version is incompatible.
|
|
163
|
+
*/
|
|
164
|
+
function awaitReady$(timeoutMs = READY_TIMEOUT_MS) {
|
|
165
|
+
const checkVersion = (event) => {
|
|
166
|
+
const compat = checkFirmwareCompat(event.version);
|
|
167
|
+
if (!compat.compatible) {
|
|
168
|
+
const got = compat.deviceVersion ?? 'unknown';
|
|
169
|
+
throw new Error(`Device firmware (v${got}) is incompatible with this CLI (requires ${compat.requiredRange}). Reflash with \`npm run flash\`.`);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
const mapTimeout = (context, ms) => catchError((err) => {
|
|
173
|
+
if (err instanceof Error && err.name === 'TimeoutError') {
|
|
174
|
+
throw formatTimeoutError(context, ms);
|
|
175
|
+
}
|
|
176
|
+
throw err;
|
|
177
|
+
});
|
|
178
|
+
// The device only sends MSG_READY in response to CMD_HELLO, so poll
|
|
179
|
+
// HELLO at a steady interval until a ready arrives. The first tick fires
|
|
180
|
+
// immediately. Best-effort writes: during the post-restart USB-CDC
|
|
181
|
+
// re-enumeration window the transport may reject — swallow and retry on
|
|
182
|
+
// the next tick.
|
|
183
|
+
const hello$ = timer(0, HELLO_POLL_INTERVAL_MS).pipe(tap(() => {
|
|
184
|
+
transport.write(buildHelloCommand()).catch(() => { });
|
|
185
|
+
}), ignoreElements());
|
|
186
|
+
// Wait for a ready event whose sequence number is newer than the one
|
|
187
|
+
// captured at the most recent `session.restart()` call. This skips any
|
|
188
|
+
// cached pre-restart ready that shareReplay would otherwise replay, so
|
|
189
|
+
// we don't proceed to send commands while the device is still in the
|
|
190
|
+
// middle of rebooting.
|
|
191
|
+
const ready$ = readyWithMeta$.pipe(filter(({ seq, arrivedAt }) => seq > lastSeenRestartSeq && arrivedAt >= lastRestartAt + POST_RESTART_BLACKOUT_MS), map(({ event }) => event));
|
|
192
|
+
return merge(hello$, ready$).pipe(first(), timeout(timeoutMs), mapTimeout('waiting for device ready', timeoutMs), tap(checkVersion));
|
|
193
|
+
}
|
|
194
|
+
/** Promise version for config operations */
|
|
195
|
+
async function awaitReady() {
|
|
196
|
+
await firstValueFrom(awaitReady$());
|
|
197
|
+
}
|
|
198
|
+
// ── Deploy ─────────────────────────────────────────────────────
|
|
199
|
+
function deploy(options) {
|
|
200
|
+
const readyTimeoutMs = options.timeout ?? READY_TIMEOUT_MS;
|
|
201
|
+
return concat(of({ type: 'connecting' }), awaitReady$(readyTimeoutMs).pipe(switchMap(() => from(deployAfterReady(options)))));
|
|
202
|
+
}
|
|
203
|
+
async function* deployAfterReady(options) {
|
|
204
|
+
const { files, envVars = [], force = false, erase = false, restart: shouldRestart = true, alwaysRestart = false, } = options;
|
|
205
|
+
// Freeze the device's JS runtime so user code can't interleave log
|
|
206
|
+
// output (raw or MSG_LOG) with deploy traffic during the checksum and
|
|
207
|
+
// upload phases. The device already pauses internally on the first
|
|
208
|
+
// deploy command, but that leaves a brief window before the first
|
|
209
|
+
// command arrives; sending PAUSE explicitly up front closes it.
|
|
210
|
+
// A reboot implicitly resumes; otherwise we send RESUME in the finally
|
|
211
|
+
// block. `didRestart` (not `shouldRestart`) drives that decision because
|
|
212
|
+
// the no-op/abort branch skips the restart even when shouldRestart=true.
|
|
213
|
+
await sendExpectOk(buildRuntimePauseCommand(), 'runtime pause', JS_YIELD_TIMEOUT_MS);
|
|
214
|
+
let didRestart = false;
|
|
215
|
+
try {
|
|
216
|
+
// Compute local hashes
|
|
217
|
+
const localHashes = new Map();
|
|
218
|
+
for (const file of files) {
|
|
219
|
+
localHashes.set(file.path, createHash('sha256').update(file.data).digest());
|
|
220
|
+
}
|
|
221
|
+
const filesToPut = [];
|
|
222
|
+
const filesToKeep = [];
|
|
223
|
+
// With erase, the checksum-based KEEP optimization is unsafe: erase wipes
|
|
224
|
+
// the live appDir before KEEP operations copy from it, so any file marked
|
|
225
|
+
// KEEP would silently drop out of the deploy. Force all files to PUT.
|
|
226
|
+
if (force || erase) {
|
|
227
|
+
filesToPut.push(...files);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
// Checksum-based incremental deploy
|
|
231
|
+
let checksumSupported = true;
|
|
232
|
+
for (let i = 0; i < files.length; i++) {
|
|
233
|
+
const file = files[i];
|
|
234
|
+
yield { type: 'checking', file: file.path, index: i, total: files.length };
|
|
235
|
+
if (!checksumSupported) {
|
|
236
|
+
filesToPut.push(file);
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
const hash = localHashes.get(file.path);
|
|
240
|
+
const resp = await sendAndWait(buildDeployChecksumCommand(file.path, hash), `deploy checksum '${file.path}'`);
|
|
241
|
+
if (resp.type === 'err') {
|
|
242
|
+
checksumSupported = false;
|
|
243
|
+
filesToPut.push(file);
|
|
244
|
+
filesToKeep.length = 0;
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
if (resp.type === 'checksum_result' && resp.match) {
|
|
248
|
+
filesToKeep.push(file.path);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
filesToPut.push(file);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// Env vars: diff against current device state so we only mutate
|
|
256
|
+
// actual differences. Firmware reports per-entry changed/existed bits,
|
|
257
|
+
// giving the CLI a definitive "did anything change" signal without
|
|
258
|
+
// any local caching.
|
|
259
|
+
const envChanged = [];
|
|
260
|
+
const envRemoved = [];
|
|
261
|
+
if (envVars.length > 0) {
|
|
262
|
+
const tooLong = envVars.filter((v) => Buffer.byteLength(v.key, 'utf-8') > 15);
|
|
263
|
+
if (tooLong.length > 0) {
|
|
264
|
+
throw new Error(`Env key(s) exceed NVS 15-char limit: ${tooLong.map((v) => v.key).join(', ')}`);
|
|
265
|
+
}
|
|
266
|
+
const deviceEntries = await config.list();
|
|
267
|
+
const desiredKeys = new Set(envVars.map((v) => v.key));
|
|
268
|
+
for (const v of envVars) {
|
|
269
|
+
const payload = await sendExpectOk(buildConfigSetCommand(v.key, v.value, v.secret), `config set '${v.key}'`);
|
|
270
|
+
if (payload.length > 0 && payload[0] === 1)
|
|
271
|
+
envChanged.push(v.key);
|
|
272
|
+
}
|
|
273
|
+
for (const entry of deviceEntries) {
|
|
274
|
+
if (desiredKeys.has(entry.key))
|
|
275
|
+
continue;
|
|
276
|
+
const payload = await sendExpectOk(buildConfigDeleteCommand(entry.key), `config delete '${entry.key}'`);
|
|
277
|
+
if (payload.length > 0 && payload[0] === 1)
|
|
278
|
+
envRemoved.push(entry.key);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
const envActuallyChanged = envChanged.length > 0 || envRemoved.length > 0;
|
|
282
|
+
const hasChanges = filesToPut.length > 0 || envActuallyChanged || erase;
|
|
283
|
+
// Nothing changed: abort. Restart anyway when the caller asked for
|
|
284
|
+
// it via alwaysRestart (mikro test wants a fresh runtime per run
|
|
285
|
+
// even when files+env are unchanged, so the supervisor re-picks up
|
|
286
|
+
// the manifest from a clean boot).
|
|
287
|
+
if (!hasChanges) {
|
|
288
|
+
await sendExpectOk(buildDeployAbortCommand(), 'deploy abort');
|
|
289
|
+
if (shouldRestart && alwaysRestart) {
|
|
290
|
+
yield { type: 'restarting' };
|
|
291
|
+
lastSeenRestartSeq = readySeq;
|
|
292
|
+
lastRestartAt = Date.now();
|
|
293
|
+
await transport.write(buildRestartCommand());
|
|
294
|
+
didRestart = true;
|
|
295
|
+
}
|
|
296
|
+
yield { type: 'complete', deployed: false, stats: { put: 0, kept: filesToKeep.length } };
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (envActuallyChanged) {
|
|
300
|
+
yield { type: 'env_changed', changed: envChanged, removed: envRemoved };
|
|
301
|
+
}
|
|
302
|
+
// Erase
|
|
303
|
+
if (erase) {
|
|
304
|
+
await sendExpectOk(buildDeployEraseCommand(), 'deploy erase');
|
|
305
|
+
}
|
|
306
|
+
// KEEP unchanged files
|
|
307
|
+
for (const filePath of filesToKeep) {
|
|
308
|
+
await sendExpectOk(buildDeployKeepCommand(filePath), `deploy keep '${filePath}'`);
|
|
309
|
+
}
|
|
310
|
+
// PUT changed/new files
|
|
311
|
+
for (let i = 0; i < filesToPut.length; i++) {
|
|
312
|
+
const file = filesToPut[i];
|
|
313
|
+
yield { type: 'uploading', file: file.path, index: i, total: filesToPut.length };
|
|
314
|
+
await streamPutFile(file.path, file.data);
|
|
315
|
+
}
|
|
316
|
+
// PUT checksums manifest — but only if we actually have files to track.
|
|
317
|
+
// Otherwise an empty-files + erase deploy would write a stub .checksums
|
|
318
|
+
// file back into /app and defeat the erase.
|
|
319
|
+
if (filesToPut.length > 0 || filesToKeep.length > 0) {
|
|
320
|
+
const manifest = buildChecksumsManifest(localHashes);
|
|
321
|
+
await streamPutFile(CHECKSUMS_PATH, manifest);
|
|
322
|
+
}
|
|
323
|
+
// Finalize
|
|
324
|
+
await sendExpectOk(buildDeployDoneCommand(), 'deploy done');
|
|
325
|
+
if (shouldRestart) {
|
|
326
|
+
yield { type: 'restarting' };
|
|
327
|
+
lastSeenRestartSeq = readySeq;
|
|
328
|
+
lastRestartAt = Date.now();
|
|
329
|
+
await transport.write(buildRestartCommand());
|
|
330
|
+
didRestart = true;
|
|
331
|
+
}
|
|
332
|
+
yield {
|
|
333
|
+
type: 'complete',
|
|
334
|
+
deployed: true,
|
|
335
|
+
stats: { put: filesToPut.length, kept: filesToKeep.length },
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
finally {
|
|
339
|
+
// If we didn't actually restart (no-op abort, thrown error, or
|
|
340
|
+
// shouldRestart=false), the runtime is still paused on the device.
|
|
341
|
+
// Resume it so the user's app keeps running. Best-effort: a dropped
|
|
342
|
+
// transport leaves the session_end hook to resume anyway.
|
|
343
|
+
if (!didRestart) {
|
|
344
|
+
try {
|
|
345
|
+
await sendExpectOk(buildRuntimeResumeCommand(), 'runtime resume', JS_YIELD_TIMEOUT_MS);
|
|
346
|
+
}
|
|
347
|
+
catch {
|
|
348
|
+
// Transport likely gone; session_end on device will resume.
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
// ── Erase app ──────────────────────────────────────────────────
|
|
354
|
+
/** Erase the deployed app without going through the full deploy flow.
|
|
355
|
+
* Sends CMD_DEPLOY_ERASE + CMD_DEPLOY_DONE directly, so the device wipes
|
|
356
|
+
* /appfs/app and the DONE handler's stamp_checksums_manifest() silently
|
|
357
|
+
* no-ops because /appfs/app no longer exists. Nothing gets staged or
|
|
358
|
+
* written back. Optionally restarts the device afterwards. */
|
|
359
|
+
async function eraseApp(options = {}) {
|
|
360
|
+
const { restart: shouldRestart = true } = options;
|
|
361
|
+
await awaitReady();
|
|
362
|
+
await sendExpectOk(buildDeployEraseCommand(), 'deploy erase');
|
|
363
|
+
await sendExpectOk(buildDeployDoneCommand(), 'deploy done');
|
|
364
|
+
if (shouldRestart) {
|
|
365
|
+
lastSeenRestartSeq = readySeq;
|
|
366
|
+
lastRestartAt = Date.now();
|
|
367
|
+
await transport.write(buildRestartCommand());
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
// ── Config ─────────────────────────────────────────────────────
|
|
371
|
+
const config = {
|
|
372
|
+
async list() {
|
|
373
|
+
await awaitReady();
|
|
374
|
+
const resp = await sendAndWait(buildConfigListCommand(), 'config list');
|
|
375
|
+
if (resp.type === 'err')
|
|
376
|
+
throw new Error(`config list: ${resp.message}`);
|
|
377
|
+
if (resp.type === 'config_entries')
|
|
378
|
+
return resp.entries;
|
|
379
|
+
throw new Error(`config list: unexpected response type '${resp.type}'`);
|
|
380
|
+
},
|
|
381
|
+
async set(key, value, secret) {
|
|
382
|
+
await awaitReady();
|
|
383
|
+
await sendExpectOk(buildConfigSetCommand(key, value, secret), `config set '${key}'`);
|
|
384
|
+
},
|
|
385
|
+
async delete(key) {
|
|
386
|
+
await awaitReady();
|
|
387
|
+
await sendExpectOk(buildConfigDeleteCommand(key), `config delete '${key}'`);
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
// ── Public API ─────────────────────────────────────────────────
|
|
391
|
+
return {
|
|
392
|
+
messages$,
|
|
393
|
+
ready$,
|
|
394
|
+
awaitReady$,
|
|
395
|
+
eval(code) {
|
|
396
|
+
void transport.write(buildEvalCommand(code));
|
|
397
|
+
},
|
|
398
|
+
directive(name) {
|
|
399
|
+
void transport.write(buildDirectiveCommand(name));
|
|
400
|
+
},
|
|
401
|
+
complete(partial) {
|
|
402
|
+
void transport.write(buildCompleteCommand(partial));
|
|
403
|
+
},
|
|
404
|
+
exit() {
|
|
405
|
+
void transport.write(buildExitCommand());
|
|
406
|
+
},
|
|
407
|
+
deploy,
|
|
408
|
+
eraseApp,
|
|
409
|
+
config,
|
|
410
|
+
restart() {
|
|
411
|
+
// Mark the current ready cache as stale so the next awaitReady$
|
|
412
|
+
// skips it and waits for a fresh post-restart MSG_READY.
|
|
413
|
+
lastSeenRestartSeq = readySeq;
|
|
414
|
+
lastRestartAt = Date.now();
|
|
415
|
+
void transport.write(buildRestartCommand());
|
|
416
|
+
},
|
|
417
|
+
close() {
|
|
418
|
+
sub?.unsubscribe();
|
|
419
|
+
sub = undefined;
|
|
420
|
+
frameParser.flush();
|
|
421
|
+
},
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
// ── Frame → Event mapping ──────────────────────────────────────────
|
|
425
|
+
function frameToEvent(frame) {
|
|
426
|
+
const msg = frameToMessage(frame);
|
|
427
|
+
if (!msg)
|
|
428
|
+
return null;
|
|
429
|
+
switch (msg.type) {
|
|
430
|
+
case 'ready': {
|
|
431
|
+
let chip = null;
|
|
432
|
+
let id = null;
|
|
433
|
+
let version = null;
|
|
434
|
+
try {
|
|
435
|
+
const info = decodeCbor(msg.payload);
|
|
436
|
+
chip = info.chip ?? null;
|
|
437
|
+
id = info.id ?? null;
|
|
438
|
+
version = info.v ?? null;
|
|
439
|
+
}
|
|
440
|
+
catch {
|
|
441
|
+
// ignore
|
|
442
|
+
}
|
|
443
|
+
return { type: 'ready', chip, id, version };
|
|
444
|
+
}
|
|
445
|
+
case 'log':
|
|
446
|
+
case 'warn':
|
|
447
|
+
case 'error':
|
|
448
|
+
case 'info':
|
|
449
|
+
case 'debug':
|
|
450
|
+
case 'result':
|
|
451
|
+
case 'eval_error':
|
|
452
|
+
return { type: msg.type, text: msg.payload.toString('utf-8') };
|
|
453
|
+
case 'completions': {
|
|
454
|
+
const result = parseCompletions(msg.payload);
|
|
455
|
+
return result ? { type: 'completions', result } : null;
|
|
456
|
+
}
|
|
457
|
+
case 'prompt':
|
|
458
|
+
return { type: 'prompt', timing: msg.payload.toString('utf-8') };
|
|
459
|
+
case 'ok':
|
|
460
|
+
return { type: 'ok', payload: msg.payload };
|
|
461
|
+
case 'err':
|
|
462
|
+
return { type: 'err', message: msg.payload.toString('utf-8') };
|
|
463
|
+
case 'checksum_result':
|
|
464
|
+
return { type: 'checksum_result', match: msg.payload.length > 0 && msg.payload[0] === 1 };
|
|
465
|
+
case 'config_entries': {
|
|
466
|
+
let entries = [];
|
|
467
|
+
try {
|
|
468
|
+
entries = decodeCbor(msg.payload);
|
|
469
|
+
}
|
|
470
|
+
catch {
|
|
471
|
+
// ignore
|
|
472
|
+
}
|
|
473
|
+
return { type: 'config_entries', entries };
|
|
474
|
+
}
|
|
475
|
+
case 'test': {
|
|
476
|
+
try {
|
|
477
|
+
const data = JSON.parse(msg.payload.toString('utf-8'));
|
|
478
|
+
return { type: 'test', data };
|
|
479
|
+
}
|
|
480
|
+
catch {
|
|
481
|
+
return null;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
case 'manifest_done':
|
|
485
|
+
return { type: 'manifest_done' };
|
|
486
|
+
default:
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/cli/lib/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAC,MAAM,IAAI,UAAU,EAAC,MAAM,OAAO,CAAA;AAC1C,OAAO,EACL,UAAU,EACV,MAAM,EACN,MAAM,EACN,QAAQ,EACR,KAAK,EACL,cAAc,EACd,IAAI,EACJ,cAAc,EACd,GAAG,EACH,KAAK,EACL,QAAQ,EAER,EAAE,EACF,KAAK,EACL,WAAW,EAEX,SAAS,EACT,GAAG,EACH,OAAO,EACP,KAAK,GACN,MAAM,MAAM,CAAA;AAEb,OAAO,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAA;AACvD,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EAGzB,WAAW,EACX,cAAc,EACd,gBAAgB,GACjB,MAAM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{
|
|
3
|
+
memLimit: number;
|
|
4
|
+
fsLimit: number;
|
|
5
|
+
fsRoot: string;
|
|
6
|
+
/** Resolved fs_read_max in bytes. Undefined means "use runtime default". */
|
|
7
|
+
fsReadMax: number | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare function resolveSimConfig(config: MikroJSConfig | null): ResolvedSimConfig;
|
|
10
|
+
/**
|
|
11
|
+
* Convenience: walk up from `startDir` (or cwd) looking for `mikro.config.ts`,
|
|
12
|
+
* then resolve the sim section with defaults filled in.
|
|
13
|
+
*/
|
|
14
|
+
export declare function loadSimConfig(startDir?: string): Promise<ResolvedSimConfig>;
|
|
15
|
+
//# sourceMappingURL=simConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simConfig.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/simConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AAK1D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,4EAA4E;IAC5E,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B;AAKD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,GAAG,iBAAiB,CAShF;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAGjF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as pathlib from 'node:path';
|
|
2
|
+
import { loadMikroConfig } from './loadMikroConfig.js';
|
|
3
|
+
import { parseSize } from './parseSize.js';
|
|
4
|
+
import { getMikroDir } from './projectRoot.js';
|
|
5
|
+
const DEFAULT_MEM_LIMIT = 300 * 1024;
|
|
6
|
+
const DEFAULT_FS_LIMIT = 1024 * 1024;
|
|
7
|
+
export function resolveSimConfig(config) {
|
|
8
|
+
const sim = config?.sim ?? {};
|
|
9
|
+
return {
|
|
10
|
+
memLimit: sim.memLimit !== undefined ? parseSize(sim.memLimit) : DEFAULT_MEM_LIMIT,
|
|
11
|
+
fsLimit: sim.fsLimit !== undefined ? parseSize(sim.fsLimit) : DEFAULT_FS_LIMIT,
|
|
12
|
+
fsRoot: sim.fsRoot ?? pathlib.join(getMikroDir(), 'sim-fs'),
|
|
13
|
+
// fsReadMax is a top-level option (applies on device and sim alike).
|
|
14
|
+
fsReadMax: config?.fsReadMax !== undefined ? parseSize(config.fsReadMax) : undefined,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Convenience: walk up from `startDir` (or cwd) looking for `mikro.config.ts`,
|
|
19
|
+
* then resolve the sim section with defaults filled in.
|
|
20
|
+
*/
|
|
21
|
+
export async function loadSimConfig(startDir) {
|
|
22
|
+
const config = await loadMikroConfig(startDir ?? process.cwd());
|
|
23
|
+
return resolveSimConfig(config);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=simConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simConfig.js","sourceRoot":"","sources":["../../../src/cli/lib/simConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA;AAGpC,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAA;AAU5C,MAAM,iBAAiB,GAAG,GAAG,GAAG,IAAI,CAAA;AACpC,MAAM,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAAA;AAEpC,MAAM,UAAU,gBAAgB,CAAC,MAA4B;IAC3D,MAAM,GAAG,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,CAAA;IAC7B,OAAO;QACL,QAAQ,EAAE,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,iBAAiB;QAClF,OAAO,EAAE,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,gBAAgB;QAC9E,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC;QAC3D,qEAAqE;QACrE,SAAS,EAAE,MAAM,EAAE,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;KACrF,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,QAAiB;IACnD,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;IAC/D,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAA;AACjC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pid file management for the simulator.
|
|
3
|
+
*
|
|
4
|
+
* One sim process at a time per project. Long-lived commands (`mikro sim dev`,
|
|
5
|
+
* `mikro sim repl`) claim the pid file and kill any predecessor. Short-lived
|
|
6
|
+
* commands (`mikro sim deploy`, `mikro sim test`, etc.) check the pid file
|
|
7
|
+
* and refuse to run if a sim is already alive — they would race on sim-fs
|
|
8
|
+
* writes or yank files out from under the running process.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isAlive(pid: number): boolean;
|
|
11
|
+
export declare function readPid(mikroDir: string): number | null;
|
|
12
|
+
export declare function clearPid(mikroDir: string): void;
|
|
13
|
+
export declare class SimAlreadyRunningError extends Error {
|
|
14
|
+
pid: number;
|
|
15
|
+
constructor(pid: number);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Refuse to proceed if a sim is already running. Used by short-lived commands
|
|
19
|
+
* (deploy, test, env, profile, clean, reset).
|
|
20
|
+
*/
|
|
21
|
+
export declare function checkPid(mikroDir: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Claim the pid file for this process. If a predecessor is alive, kill it
|
|
24
|
+
* first (SIGTERM, then SIGKILL after a short grace period). Registers exit
|
|
25
|
+
* cleanup to remove the file on normal termination.
|
|
26
|
+
*
|
|
27
|
+
* Used by long-lived commands (dev, repl).
|
|
28
|
+
*/
|
|
29
|
+
export declare function claimPid(mikroDir: string): Promise<void>;
|
|
30
|
+
//# sourceMappingURL=simPid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simPid.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/simPid.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAQ5C;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAmBvD;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAO/C;AAED,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,GAAG,EAAE,MAAM,CAAA;gBACC,GAAG,EAAE,MAAM;CAOxB;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAG/C;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkC9D"}
|