Common Code section

Hi @Nick_W,
I’ve been thinking about something similar. The JS language has the module system which should work for this sort of thing.

Importing could have double benefits, allowing a pattern to import others in order to compose them, sequence, etc., and/or as a way to act as a library by consuming exported APIs.

Some global code could help give advanced configuration and behavior to the whole Pixelblaze. Maybe some kind of plugin/extension architecture for sharing these bits that aren’t patterns. Map code is one example, even if it runs in browser. Perhaps something that would allow you to trigger controls based on analog inputs, or adapters for network messages, automatic gain control for audio expansions, and that sort of thing. I’d want these to be more or less self-contained and independent, and having patterns depend on them could create portability issues.

For sharing code, having everything self contained really helps with sharing and distribution. I’d be very tempted to bundle up everything that the pattern imported so you don’t end up with a broken pattern, and it gets a bit tricky if you wanted to load a pattern that was bundled with a bunch of things, especially if those names were taken in the global namespace. For that to work without conflict, we’d need something like local packages. Theres a lot of ways of doing it, but I want it to work seamlessly and intuitively for beginner coders.

I’m currently leaning toward allowing multiple files in a pattern. These might be in an emulated filesystem with directories with a file list view and/or editor tabs, and support embedding documentation and possibly media assets in the future. Having a “standard library” as a secondary source would make the copy+paste a bit easier and cleaner, and would still be self contained for export/import.

2 Likes