-
-
Notifications
You must be signed in to change notification settings - Fork 850
[PoC] feat: introduce Moddable adapter #4284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4284 +/- ##
==========================================
+ Coverage 91.61% 91.79% +0.18%
==========================================
Files 170 177 +7
Lines 10875 11239 +364
Branches 3099 3280 +181
==========================================
+ Hits 9963 10317 +354
- Misses 911 921 +10
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Is this ready for review? If it's ready, please ping me! |
|
@yusukebe Yes! Could you review this? |
|
Hi @nakasyou I think this is interesting, but we have some issues.
So, I think it's better to add it to What do you think of it? |
Moddable is a sdk enables embedded systems or microcontrollers such as ESP32, Raspberry Pi Pico and others to run JavaScript code, using XS, tiny JavaScript runtime. This PR allows us to run Hono apps on microcontrollers and develop IoT devices using Hono via Moddable.
Usage
manifest.json{ "include": [ "$(MODDABLE)/examples/manifest_base.json", "$(MODDABLE)/examples/manifest_net.json", "$(MODULES)/network/http/manifest.json", "$(MODDABLE)/modules/data/headers/manifest.json", "$(MODDABLE)/modules/data/url/manifest.json", "$(MODDABLE)/modules/data/text/encoder/manifest.json", "$(MODDABLE)/modules/data/text/decoder/manifest.json", "$(MODDABLE)/modules/data/headers/manifest.json", "$(MODDABLE)/modules/network/websocket/manifest.json" ], "modules": { "*": [ "$(MODDABLE)/examples/io/streams/modules/streams.js", "./dist/main.js" ] }, "creation": { "stack": 512, "heap": { "initial": 9856 } }, "preload": [ "streams" ] }main.tsbun build main.ts --outdir dist --external streams --external embedded:network/http/server --external socket --external text/encoder --external text/decoder --external websocket --external headers --target node --watchmcconfig -d -m -p <device>Tested device
Features
Notes
Why not to use
httpmoduleThe adapter doesn't use
httpmodule. This is because Moddable's defaulthttpmodule doesn't support async function.httpmodule is simple and usessocketmodule, so I implemented HTTP/1.1 protocol. Andhttpmodule supports only HTTP/1.1 protocol, so I implemented like that.Why to use Hono
Because I don't know any HTTP frameworks I can use with Moddable. Also, Hono is tiny, and embedded systems has limited storage, so Hono is suitable for embedded systems to use JavaScript I thought.
Why this PR doesn't include moddable test for GitHub Actions
I don't know how to test with moddable environment on GitHub Actions. I'm not sure but maybe it's because GitHub Actions don't have GUI. I tried to fix it, but I can't fix in my skill.
Why not to publish on JSR
Because the code depends on runtime-specific APIs can't be published to JSR. jsr-io/jsr#1160
Also, thanks to @stc1988, I was able to improve this.
The author should do the following, if applicable
bun run format:fix && bun run lint:fixto format the code