abstreet/web/README.md
Michael Kirk 4f81f186af
embed mode and reworked web build system (#592)
* root element id from Settings, respect element size

* Plumb assets root via settings

* adapt crates to new wasm api

* more FileLoader cleanup

* use tsc bin from node_modules

* avoid spurious unlink errors

GNU Make considers the src/*/wasm_pkg targets as intermediate build
files and attempted to `rm` them. We can stop that my marking them as
`.PRECIOUS`

https://www.gnu.org/software/make/manual/html_node/Special-Targets.html

* `open` doesn't work on Linux

We could do something with xdg-open, but meh, not worth having platform
dependent logic for this.

* fix typo, clarify instructions

* make server compatible with older python install on linux

* revert change - we dont want to include music on web

the leading "-" means exclude a subdir of an included dir.

* better wrap of comments

* fix misfire in copy/pasted comment

* update docs
2021-04-01 19:31:02 -07:00

1.2 KiB

Web Stuff

This is a collection of API's and build tools for packaging our various Widgetry apps as web applications.

Goals

A web developer, who might not know anything about rust or wasm, should be able to use our packaged javascript libraries on their website with minimal customization or arcanery.

Users of their website should be able to interact with the widgetry app without it feeling weird or having to jump through hoops.

Limitations

JS feature: import.meta

To allow the application to live at any URL (rather than presupposing it lives at root, or whatever), we rely on import.meta which isn't supported on some browsers before 2018. See: https://caniuse.com/?search=import.meta

An alternative would be to require configuration, so the loader knows where to download it's "*_wasm.bg file".

Browser Feature: WebGL

We prefer WebGL2, but now gracefully fall back to WebGL1. This should cover all common browsers since late 2014. https://caniuse.com/?search=webgl

Examples

See src/web_root/*.js for code examples.

You can build and see the examples in your webbrowser with:

// install typescript build dependency
npm install
make build
make server