-
-
Notifications
You must be signed in to change notification settings - Fork 293
fix: share internal state across duplicate library copies #1469
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 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6ab3bda
fix: share internal state across duplicate library copies
franky47 b448210
ref: single source for the injected version literal
franky47 416de59
test: pin cross-copy optimistic sync and context React-keying
franky47 b38842a
build: fail prepack when the version placeholder is missing from dist
franky47 6bcb7fe
clean: align comments with shared-context behavior
franky47 1d81c81
doc: flag the context weak-keying for reassessment in nuqs@3
franky47 ed1db7d
Merge remote-tracking branch 'origin/next' into fix/duplicate-library…
franky47 92dfab3
fix: share adapter history emitters across copies
franky47 d8e757f
fix: share Pages Router update guard across copies
franky47 7422d9f
fix: support non-extensible globalThis
franky47 2295437
fix: make version placeholder check batch-safe
franky47 39d2c47
fix: reset Pages Router update guard on throw
franky47 b24d6ac
doc: update duplicate copy error guidance
franky47 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { afterEach, describe, expect, it, vi } from 'vitest' | ||
| import { version } from '../../lib/version' | ||
|
|
||
| describe('adapter context keying across React instances', () => { | ||
| afterEach(() => { | ||
| vi.doUnmock('react') | ||
| vi.resetModules() | ||
| const registry = globalThis as { [key: symbol]: unknown } | ||
| delete registry[Symbol.for(`nuqs.${version}.adapter-context`)] | ||
| }) | ||
|
|
||
| it('keeps contexts isolated across distinct createContext identities', async () => { | ||
| const real = await import('./context') | ||
| vi.resetModules() | ||
| vi.doMock('react', async importOriginal => { | ||
| const actual = await importOriginal<typeof import('react')>() | ||
| const createContext: typeof actual.createContext = defaultValue => | ||
| actual.createContext(defaultValue) | ||
| return { ...actual, createContext } | ||
| }) | ||
| const other = await import('./context') | ||
| expect(other.context).not.toBe(real.context) | ||
| }) | ||
| }) |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: 47ng/nuqs
Length of output: 177
🏁 Script executed:
Repository: 47ng/nuqs
Length of output: 1341
🏁 Script executed:
Repository: 47ng/nuqs
Length of output: 213
🏁 Script executed:
Repository: 47ng/nuqs
Length of output: 712
🏁 Script executed:
Repository: 47ng/nuqs
Length of output: 182
Guard can fail spuriously when
findsplits-execacross batches.grep -qreturns 1 for any batch that doesn’t contain the placeholder, andfindpropagates that non-zero status even if another batch matched. A largerdisttree can therefore break this release check; usegrep -rq "0.0.0-inject-version-here" dist --include="*.js"instead.🤖 Prompt for AI Agents