README.md (2050B)
1 # Template runtime proof of concept 2 3 This directory is an isolated prototype for the template package runtime. It does not change the production apps. 4 5 ## Run 6 7 ```sh 8 npm install 9 npm run build 10 npm start 11 ``` 12 13 Open `http://localhost:4173`. 14 15 OPFS requires a secure context. On plain HTTP hosts other than localhost, the PoC falls back to an in-memory cache and logs a warning. Use localhost or HTTPS to exercise OPFS persistence. 16 17 ## The proof 18 19 - `.tar.gz` packages built with `modern-tar`. 20 - Content-addressed layers stored in OPFS. 21 - Arbitrary ordered overlay layers, with the last layer winning per file. 22 - HBS pages and partials from the merged layer stack. 23 - `template://` CSS and image links resolved to object URLs. 24 - CSS `@import` and `url()` rewriting across layers. 25 - Handlebars rendering with delegated behavior and no Mithril. 26 - Sanitized template output with scripts and external assets rejected. 27 - Cache reuse across reloads. 28 29 ## Demo layers 30 31 - `system` is the complete base package. 32 - `acme-brand` overrides the topbar partial and global color tokens. 33 - `acme-holiday` overrides the login page and login CSS. 34 - Both overlays can be enabled together to demonstrate three-layer resolution. 35 36 ## Runtime layout 37 38 ```text 39 src/main.ts demo state and behavior 40 src/runtime/cache.ts OPFS layers, composites and metadata 41 src/runtime/tar.ts download, digest check and extraction 42 src/runtime/layers.ts layer merge and page resolution 43 src/runtime/assets.ts template:// and CSS asset rewriting 44 src/runtime/render.ts Handlebars compilation and partials 45 src/runtime/actions.ts delegated actions, forms and routes 46 src/runtime/router.ts hash based demo router 47 ``` 48 49 ## Limits 50 51 - PoC icons are inline SVG. 52 - The production template build should generate Lucide SVG files and reference those from templates instead of embedding SVG in HBS. 53 - Client-specific overlays are not part of the backend plan yet. 54 - The production manifest endpoint, upload API, storage and admin UI are not implemented here.