Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Frida854
    @Frida854
    @johnwargo
    I'm sorry, it should not happen again.
    Daniel Ashcraft
    @dashcraft
    @johnwargo you might make sure that you only have 1 version of python installed. I had 3 versions, 2.7, 3.2 and 3.9,
    i kept getting dependency errors because all 3 conflicted with my python terminal usage. After deleting all but the latest
    and running the python package commands again, everything worked fine.
    John M. Wargo
    @johnwargo
    @dashcraft thanks for that. I should only have one Python version running, the output above only shows one. I read an article about how to install a newer version of Python on macOS (over the macOS installed one) so I'm using pyenv https://opensource.com/article/19/5/python-3-default-mac
    Andy Carle
    @PrototypingAndy_twitter
    @johnwargo Good afternoon. Any chance that something later in your .zshrc is overriding a path set by $IDF_PATH/export.sh? You might try just doing a source $IDF_PATH/export.shin the terminal right before building to see if that helps any.

    You could also try building a standard ESP-IDF example. If your shell environment is properly configured, something like this should complete successfully:

    cd $IDF_PATH/examples/get-started/hello_world
    idf.py build flash monitor

    If that doesn't work, your issue is something outside of Moddable land.

    John M. Wargo
    @johnwargo

    @dashcraft

    @johnwargo you might make sure that you only have 1 version of python installed. I had 3 versions, 2.7, 3.2 and 3.9,
    i kept getting dependency errors because all 3 conflicted with my python terminal usage. After deleting all but the latest
    and running the python package commands again, everything worked fine.

    Yeah, so I have three copies: the macOS one, my pyenv one and the one that comes with the esp32 SDK.

    ❯ where python
    /Users/johnwargo/.pyenv/shims/python
    /Users/johnwargo/.espressif/python_env/idf4.2_py3.9_env/bin/python
    /usr/bin/python

    Its my understanding I can't whack the Apple one (please correct me if I'm wrong), but I can redo the ESP32 installation without Python and see what happens.

    John M. Wargo
    @johnwargo
    @PrototypingAndy_twitter that did work, so outside of Moddable land works. the source command was in my ~./zshrc file only once, but I removed it and executed it manually in the terminal window.
    John M. Wargo
    @johnwargo
    hmmm, the idf install installs python automatically and, of course, puts it in the PATH. I'm not sure what to do with that.
    John M. Wargo
    @johnwargo
    Alright, @dashcraft was right - when I removed my pyenv python stuff from the ~/.zshrc it works.
    ❯ where python
    /Users/johnwargo/.espressif/python_env/idf4.2_py3.9_env/bin/python
    /usr/bin/python
    Peter Hoddie
    @phoddie
    Three cheers for @dashcraft! Thank you!
    Daniel Ashcraft
    @dashcraft
    Heyo! Awesome!
    Daniel Ashcraft
    @dashcraft
    Are there any successful apple home kit integrations using moddable sdk?
    Peter Hoddie
    @phoddie
    Good question. Some years ago the Kinoma team at Marvell did have HomeKit working with Kinoma Element. That's relevant because it was built on XS and an earlier version of our TLS stack. I believe it made use of some crypto features that haven't been migrated to the Moddable SDK yet, but it would be some work figure out what is needed (and HomeKit has changed since then). Beyond the crypto work, it should be straightforward (and the crypto work should be straightforward for someone comfortable with that)
    Daniel Ashcraft
    @dashcraft
    Idk if anyone is interested in this kind of stuff, but toit.io and toit lang looks fairly promising, however they've gone the route of vc funding which means you gotta pay the bridge troll to play
    Daniel Ashcraft
    @dashcraft
    Does moddable sdk minimize the js files/bundle js files or do any tree shaking of dependencies?
    Andy Carle
    @PrototypingAndy_twitter
    For the XS engine itself, the Moddable SDK strips unused features by default. See Strip Unused Features in the "XS Differences" document and the associated note in the manifest documentation. If you're talking about application files, the build tools just go by what they're told to do in the manifest.
    Daniel Ashcraft
    @dashcraft

    Good question, im contemplating some build tooling similar to what I get in web. If I use import { debounce } from 'lodash' for instance, it won't import
    the entire library, but it'll import the destructured method that's used and the rest of the dependencies "shake" off so to speak.

    I'm interested if anyone has used a bundler or js minifier with success, up to and including tree shaking, to reduce end bundle size.

    I apologize in advance for my lack of knowledge in this area, I'm used to the web world and I'm contemplating building an expressJs like router for
    moddable sdk wanted to make sure i didn't go down a path that left too many unused deps
    Peter Hoddie
    @phoddie
    Minifiers for the web are generally focused on making the JavaScript source text small. On an embedded device with the Moddable SDK the JavaScript is usually precompiled so shrinking the source text isn't always helpful. In some cases, it can make the code bigger. For example, a minifier may replace "false" with "!1" to save three byes. But, it will generate bigger (and slower) bytecode when built for embedded. Similarly, many of the goals of a bundler aren't really meaningful with the preload feature of the XS linker.
    All that said, like expressJs should very much be possible. The full expressiveness of JavaScript is there. The difference is that using it efficiently for embedded is often quite different from the web world.
    Some form of tree shaking for modules should be possible and would be great for helping keep firmware sizes down. It just looks like a non-trivial project to sort out the right place to start and how to integrate that through the build.
    Daniel Ashcraft
    @dashcraft

    Hmmmm very interesting. Is there any current moddable sdk npm style packages that have been used and work well that I could emulate?

    I also have some resources in the webpack and older gulpjs community I might be able to leverage.

    Peter Hoddie
    @phoddie
    Sorry, no NPM packages (hard as that may be to believe!)
    Peter Hoddie
    @phoddie
    Each .js fie in $MODDABLE/modules/ is a real ECMAScript module. It should be straightforward to put together an npm style package for them.
    Daniel Ashcraft
    @dashcraft
    @phoddie are there any plans for js sandboxing or using vm's for dedicated isolated app environments?
    Peter Hoddie
    @phoddie
    XS is the only engine to implement Secure ECMAScript natively. That provides Compartments which is a low-overhead way to virtualize/sandbox JavaScript code. The Secure ECMAScript section of this blog post is a good place to start learning about that, though a few of the details are out-of-date.
    This talk includes a demo of using Secure ECMAScript to sandbox JavaScript extensions to the firmware of a lightbulb. It is from a meet-up sponsored by Agoric, the folks who have been working on JavaScript virtualization longer than anyone.
    Daniel Ashcraft
    @dashcraft
    Very interesting, very very interesting
    Daniel Ashcraft
    @dashcraft
    Probably a question that's answered somewhere in the docs, but how do you parse a posted body through the http server?
    I'm trying to acccess incoming headers and data/body
    Daniel Ashcraft
    @dashcraft
    I’ve actually figured out headers, working on bodies, disregard
    Peter Hoddie
    @phoddie
    The httpserverputfile example is a good place to start for receiving the body in chunks.
    Daniel Ashcraft
    @dashcraft
    Another potential silly question, i don't see many docs explaining nested file includes. It seems as though each
    file needs to be included as a module. Are there examples i can reference for local nested file includes?
    image.png
    fwiw, i have this working fine
    Peter Hoddie
    @phoddie
    Forgive me for answering with a silly question, by "nested file includes" what specifically do you want to do?
    (Express? Spiffy!)
    Daniel Ashcraft
    @dashcraft

    if i have a folder structure
    -main.js
    -libs
    --lib.js
    --another-lib.js

    Is there a way for me to not have to specifically include each file in the manifest.json
    I tried, "./libs/*" and it only includes the root file not subsequent files

    Peter Hoddie
    @phoddie
    Understood thanks. Yes, you can do that. If you have several modules in a directory, use the * wildcard. You can also alias the path. Here's a quick modification o the helloworld manifest to show how. the source directory is named "lib" but the modules will be available at "library/" instead of "lib/". The preload section also supports wildcards.
    {
        "include": "$(MODDABLE)/examples/manifest_base.json",
        "modules": {
            "*": [
                "./main"
            ],
            "library/*": "./lib/*"
        },
        "preload": [
            "library/*"
        ]
    }
    Daniel Ashcraft
    @dashcraft
    fantastic, i'll give that a shot tonight, i was left working in a single file and it was messing with my ocd considerably
    Daniel Ashcraft
    @dashcraft
    Had some fun, will pick at it as I need more items in the future
    Peter Hoddie
    @phoddie
    That looks interesting. TypeScript and all. ;) I'll make some time to give it a try.
    FWIW - I noticed that you have Globals.d.ts to provide a declaration for trace. The Moddable SDK includes xs.d.ts which contains all the XS extensions to JavaScript, including trace.
    Daniel Ashcraft
    @dashcraft
    I’ll get that imported in! Thanks!
    Peter Hoddie
    @phoddie
    I posted some notes in an issue in your repository. I hope that's OK. If anything is unclear, just let me know. dashcraft/express-js-mod#2
    Daniel Ashcraft
    @dashcraft
    Absolutely
    I haven’t used Object.freeze but maybe a handful of times to enforce some semblance of immutability in react, that’s pretty neat about using it for storing in ROM
    Daniel Ashcraft
    @dashcraft

    Did some work with it today, got it working decent for posted data now and put/patch data. Took a lot of your suggestions and implanted them.

    Need to work on more in the future, but get/post json and text are my two main use cases and this drastically simplifies the process of listening to and responding to requests.

    POST: sensor.local/home?id=1

    raw json body: { "test" : "control"}

    {
        "test": "test",
        "request": {
            "state": "done",
            "headers": {
                "content-type": "application/json",
                "user-agent": "PostmanRuntime/7.28.0",
                "accept": "*/*",
                "cache-control": "no-cache",
                "postman-token": "83dae780-2ef5-491d-8a3d-b2ea217c042e",
                "host": "sensor.local",
                "accept-encoding": "gzip, deflate, br",
                "connection": "keep-alive",
                "content-length": "24"
            },
            "path": "/home",
            "httpMethod": "post",
            "data": {
                "test": "control"
            },
            "params": {
                "id": "1"
            },
            "rawQuery": "id=1",
            "location": "/home?id=1"
        }
    }

    This is about as easy as it gets when it comes to receiving data in the form of json or query params.
    Need to send files and other content types in the future,

    let express = new Express(Server)
    express.get('/home', function(req,res) {
        res.json({test: 'test', request: req})
    })
    
    express.post('/home', function(req,res) {
        res.json({test: 'test', request: req})
    })
    express.listen(80)