Skip to content

Conversation

@CarlQLange
Copy link
Contributor

@CarlQLange CarlQLange commented Sep 14, 2025

Add htmllocal export to use locally built wasm, so you can use the latest (or a custom) TIC-80 build in the browser. This is a more or less a high fidelity proof of concept, it works for my use case but I'm not that sure if it is a good fit (if there are reasons for you not to want to do it this way).

Basically, we just bake the local build/html files (wasm included) into the TIC-80 executable at build time. Then when you do export htmllocal mygame, it'll use those files instead of doing a network call and getting them from the server instead (also means you can export for web while offline for what it's worth).

It works well enough for what I wanted, which was to test out the safari keyboard fix I added a PR for earlier! (#2838)

Claude code wrote practically all the code here. I will not be hurt if you don't merge this, very little human effort went into it but I do find it useful and functional :)

CarlQLange and others added 5 commits September 14, 2025 12:00
… key events with KeyboardEvent.location === 3 (numpad) to location: 0 on WebKit in capture phase\n- Prevent page scrolling on Arrow keys while canvas is focused\n- Ensure canvas is focusable (tabindex=0) and focused on start\n\nThis addresses Safari/WebKit misclassification of physical Arrow keys so games receive directional input correctly.
- Add 'export htmllocal' command for offline HTML5 export
- Embeds HTML/JS/WASM templates in binary at build time (~21MB)
- Uses local templates instead of downloading from server
- Includes JavaScript fixes for ES6 module issues and closure syntax
- Custom TIC-80 builds can now export to HTML5 without network access

Files added/modified:
- tools/embed_html.py: Script to convert files to C byte arrays
- build/embedded_html_templates.h: Generated embedded template data
- cmake/studio.cmake: Build-time template generation
- src/studio/screens/console.c: htmllocal export implementation
- build/html/export.html: JavaScript syntax fixes for embedded use

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@CarlQLange CarlQLange changed the title [WIP] Add htmllocal export to use locally built wasm [Web export] Add htmllocal export to use locally built wasm Sep 14, 2025
CarlQLange and others added 2 commits September 14, 2025 21:05
- Add BUILD_HTMLLOCAL_EXPORT CMake option (default OFF)
- Only embed templates when explicitly enabled and artifacts exist
- Prevents CI build failures when web artifacts are missing
- Runtime check for embedded templates availability
- Fails fast with clear error if enabled but artifacts not found

Usage:
- cmake .. (default) - htmllocal export disabled, no dependencies
- cmake -DBUILD_HTMLLOCAL_EXPORT=ON .. - enables feature if artifacts exist

This fixes build failures in CI environments that don't have pre-built
WASM/JS artifacts while keeping the feature available for those who need it.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Move embedded template usage inside #ifdef block
- Prevents undefined variable errors when BUILD_HTMLLOCAL_EXPORT=OFF
- Shows clear error message when feature disabled at build time
- All builds should now compile regardless of template availability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@CarlQLange
Copy link
Contributor Author

apologies about the wasted CI minutes, this stuff is a little outside my comfort zone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant