feat(render): add startup theme palette support for Q-Apps via _qdnThemePalette (Qortal-Hub#231)#318
Open
QuickMythril wants to merge 1 commit intoQortal:masterfrom
Open
Conversation
Accept optional themePalette query param on render endpoints, inject _qdnThemePalette in HTML startup globals with safe JSON handling, add dev-proxy parity, preserve palette across q-app internal links, and add parser tests for valid/invalid payloads.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds Core-side support for startup theme palette delivery to Q-Apps by accepting an optional
themePalettequery parameter on/render/*routes and injecting it into rendered HTML as:This complements the Hub work in:
and addresses the remaining startup-path gap for:
Problem
Hub now sends runtime theme updates with full palette (
THEME_CHANGEDwith{ theme, palette }), but Q-Apps also need palette data immediately at startup (before runtimepostMessage) to avoid first-paint theme drift.Before this PR, Core only injected startup globals for mode/language (
_qdnTheme,_qdnLang) and had no startup palette global.What This PR Changes
1) Render API support (additive)
/render/*endpoints now accept optional query param:themePalette(string, URL-encoded JSON object)Updated:
RenderResourceto read and forwardthemePaletteto the renderer.2) Renderer plumbing
ArbitraryDataRenderernow carries an optionalthemePalettefield and passes it intoHTMLParser.3) HTML startup global injection
HTMLParsernow:themePalette,var _qdnThemePalette = <object-or-null>;nullwhen missing, invalid JSON, or non-object payload,_qdnTheme,_qdnLang,_qdnContext, etc.) unchanged.4) Injection safety
Palette JSON is normalized and escaped for inline script context (e.g.
<,>,&, line separators) before interpolation.5) Dev proxy parity
DevProxyServerResourcenow reads optionalthemePaletteand passes it toHTMLParserso dev mode behavior matches render mode.6) Internal link propagation support (
q-apps.js)When Q-Apps build internal resource URLs, Core
q-apps.jsnow appends:themelangthemePalette(JSON.stringify+encodeURIComponent, fail-safe)It also strips
themePalettein URL parsing cleanup used for navigation history.Supported
themePaletteFormatthemePalettemust be a URL-encoded JSON object string.Example:
{"primary":"#111111","surface":{"main":"#ffffff"}}themePalette=%7B%22primary%22%3A%22%23111111%22%2C%22surface%22%3A%7B%22main%22%3A%22%23ffffff%22%7D%7DBehavior:
null.Backward Compatibility
_qdnTheme,_qdnLang, and render flows remains unchanged.themePalettecontinue to work.Validation
null,null.mvn -DskipJUnitTests=false -Dtest=org.qortal.test.api.HTMLParserTests testmvn -DskipTests packageEnd-to-End with Hub + Q-Place
With Hub
feature/theme-sharing+ Hub PR #256 behavior and this Core PR:_qdnThemePalette,THEME_CHANGED({ theme, palette }).qortal://APP/qplacesupports this feature and can be used for verification: