Repository navigation
Preserve hydration compatibility with legacy router assets #3124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7546da4
Preserve hydration compatibility with legacy router assets
kwakayama c7a6e4f
Address hydration compatibility review feedback
kwakayama a3e03e6
Anonymize customer-specific references
kwakayama 5fd028e
Bound browser bridge cleanup and bump version
kwakayama 72a0e50
Merge main and retain hydration compatibility version
kwakayama File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
53 changes: 53 additions & 0 deletions
53
src/html/hydration-script-builder/templates/navigation-store.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /** | ||
| * Generate the compatibility bridge between the shared hydration runtime and | ||
| * release-pinned router assets. | ||
| * | ||
| * Router releases since the v1 navigation store landed share the same | ||
| * Symbol.for registry entry even when they predate the public | ||
| * getNavigationStore export. Keeping the fallback store shape in sync with the | ||
| * two v1 implementations lets those releases retain SPA navigation. | ||
| */ | ||
| export const getNavigationStoreCompatibilityScript = () => ` | ||
| const navigationStoreUsesRegistryFallback = | ||
| typeof RouterRuntime.getNavigationStore !== 'function'; | ||
| const getNavigationStore = navigationStoreUsesRegistryFallback | ||
| ? () => { | ||
| const storeKey = Symbol.for('veryfront.navigation.store.v1'); | ||
| const existing = globalThis[storeKey]; | ||
| if (existing) return existing; | ||
|
|
||
| const listeners = new Set(); | ||
| let navigator = null; | ||
| const store = { | ||
| subscribe(listener) { | ||
| listeners.add(listener); | ||
| return () => listeners.delete(listener); | ||
| }, | ||
| getHref() { | ||
| const loc = globalThis.location; | ||
| return loc ? loc.pathname + loc.search + loc.hash : '/'; | ||
| }, | ||
| notify() { | ||
| for (const listener of [...listeners]) { | ||
| try { | ||
| listener(); | ||
| } catch { | ||
| // One subscriber must not prevent the others from updating. | ||
| } | ||
| } | ||
| }, | ||
| navigate(href, options) { | ||
| if (navigator) return navigator(href, options); | ||
| globalThis.location?.assign(href); | ||
| return Promise.resolve(); | ||
| }, | ||
| setNavigator(next) { | ||
| navigator = next; | ||
| }, | ||
| }; | ||
|
|
||
| globalThis[storeKey] = store; | ||
| return store; | ||
| } | ||
| : RouterRuntime.getNavigationStore; | ||
| `; |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // Keep in sync with deno.json version. | ||
| // scripts/release.ts updates this constant during releases. | ||
| /** Shared version value. */ | ||
| export const VERSION = "0.1.1156"; | ||
| export const VERSION = "0.1.1157"; |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.