feat: #shinyreact-config tag + protocol handshake, decide JS distribution - #198
Open
schloerke wants to merge 4 commits into
Open
feat: #shinyreact-config tag + protocol handshake, decide JS distribution#198schloerke wants to merge 4 commits into
schloerke wants to merge 4 commits into
Conversation
- Add decisions/2026-08-17-js-distribution.md: hybrid npm runtime (@posit/shinyreact) + HTMLDependency zero-build tier, protocol handshake via a #shinyreact-config script tag - Update DESIGN.md and conf-2026 goals to the @posit/shinyreact name
- Page entry points now always emit <script type="application/json" id="shinyreact-config"> carrying protocolVersion and, when a bookmark is restoring, the restored input values — replacing the inline JS that set window.shinyreact._restore - JS client reads the tag (legacy _restore global kept as fallback) and asserts the protocol major version, failing fast with both versions named on mismatch - PROTOCOL_VERSION declared in all three languages with parity tests pinning them to the same string - Step 1 of decisions/2026-08-17-js-distribution.md; unblocks publishing @posit/shinyreact without the global as bootstrap
schloerke
marked this pull request as ready for review
August 17, 2026 16:32
This was referenced Aug 19, 2026
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.
Refs #172. Stacked on #197 (base is
schloerke/rename-pkg-js; retarget tomainonce #197 merges).Summary
Implements step 1 of the JS-distribution decision and checks in the decision record itself (
decisions/2026-08-17-js-distribution.md: hybrid npm distribution — publish@posit/shinyreactas a real ESM runtime while keeping the IIFE HTMLDependency as the zero-build tier, with a wire-protocol handshake instead of lockstep releases).The
#shinyreact-configscript tag. Page entry points (Python_dep_page(), Rshinyreact_dep_page()) now always emit<script type="application/json" id="shinyreact-config">{"protocolVersion":"1.0","restore":{...}}</script>. This replaces the inline JS that pre-seededwindow.shinyreact._restore— the one structural dependency on the global existing before the bundle runs — with inert JSON that any future ESM client can read too. Because the payload is never parsed as JavaScript, the two-layer JS-string-literal escaping (and the U+2028/U+2029 handling from #183) collapses to a single rule: every<is emitted as the JSON escape\u003c.Protocol handshake.
PROTOCOL_VERSION = "1.0"is declared in all three languages (pkg-js/src/shiny-react/config.ts,pkg-py/src/shinyreact/_protocol.py,pkg-r/R/protocol.R); each language has a parity test pinning the three strings equal. The JS client asserts the major version at boot and throws naming both versions on mismatch — this is what lets a future npm-installed client and a pip/CRAN server release independently.Back-compat. The client still falls back to the legacy
window.shinyreact._restoreglobal when the config tag is absent (a server predating this change), and the-applied/-valuesDevTools sentinel is unchanged.Verification
helper-config.Rand mirrored against the Python test names per the parity policy.config.test.tsplus config-tag cases inuse-shiny-restore.test.tsx),tsc --noEmitclean.make update-distrebuilt and synced the bundle to both language packages.Reproduce: run a bookmarkable app (
examples/10-bookmarking), view source — the head now contains the#shinyreact-configJSON tag instead of awindow.shinyreact._restore = JSON.parse(...)script, and restored inputs behave identically.