-
Notifications
You must be signed in to change notification settings - Fork 435
chore(astro,clerk-react,shared,nextjs): Migrate functions that can be reused across JavaScript SDKs #3849
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
wobsoriano
merged 37 commits into
main
from
rob/eco-4-move-or-use-utilities-from-clerkshared
Aug 9, 2024
Merged
chore(astro,clerk-react,shared,nextjs): Migrate functions that can be reused across JavaScript SDKs #3849
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
14129c8
chore(shared): Add deriveState function
wobsoriano 4c14780
chore(astro): Use shared deriveState function
wobsoriano b181a0c
test(shared): Test deriveState with and without initial state
wobsoriano 0cadd2d
test(shared): Handle undefined initialState
wobsoriano 889fb5c
chore(shared): Add and export Clerk script hotload function
wobsoriano 5fc583a
test(astro): clean up
wobsoriano 64f1987
test(astro): add Clerk script loader tests
wobsoriano 133615e
chore(astro): Use shared script url builder when hotloading script
wobsoriano f2d5ad9
chore(astro): Use shared data attribute builder for hotloading
wobsoriano 3fca391
chore(astro): Use shared clerk-js hotload script
wobsoriano 142246c
chore(astro): Clean up type ignores
wobsoriano 09f2fde
chore(astro,shared): Add changeset
wobsoriano ea5f607
chore(shared): Add and export version selector from react package
wobsoriano cb283c6
chore(astro): Fix merge conflicts
wobsoriano d5ed822
chore(astro): Fix incorrect file name
wobsoriano 41038f8
chore(shared): Remove hardcoded version from clerk js script loader
wobsoriano 1eaee79
chore(shared): Allow custom package version
wobsoriano 84c5a46
test(shared): Handle custom package versions for versionSelector
wobsoriano 883e734
chore(shared): Improve version selector explanation
wobsoriano 7605a54
chore(astro): Use shared clerk-js hotload script
wobsoriano c9ed36e
chore(shared): Update internal package version property name
wobsoriano a76dd7b
chore(astro): Remove unused file
wobsoriano 9e6c6de
chore(astro): Clean up param names
wobsoriano 3969364
chore(clerk-react): Use shared loadClerkJsScript when hotloading Cler…
wobsoriano 06ab32e
chore(clerk-react,astro,shared): Update changeset
wobsoriano a6a3a2c
chore(shared): Make options optional in loadClerkJsScript and throw i…
wobsoriano 05b2c36
chore(shared): Update loadClerkJsScript JSDoc
wobsoriano 674f9ae
chore(shared,clerk-react): Remove __internal_packageVersion
wobsoriano 5195455
chore(shared): Use built-in errorThrower when loading clerk script
wobsoriano 2304335
chore(shared,astro,react,nextjs): Use built-in error thrower when Cle…
wobsoriano c7c6651
chore(shared,astro,react,nextjs): Update changeset
wobsoriano e23fa2c
chore(shared): Update JSDoc function name
wobsoriano 19fad8d
test(shared): Use clerk-js major version from package.json when testi…
wobsoriano 33c28b6
chore(shared): Add nonce prop to script loader options
wobsoriano e9f21ab
chore(shared): Add nonce prop to to load script
wobsoriano e5e8fba
chore(shared): Remove extra folder
wobsoriano 090f0e7
chore(shared): Add missing nonce to buildClerkJsScriptAttributes
wobsoriano 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "@clerk/astro": patch | ||
| "@clerk/shared": patch | ||
| "@clerk/clerk-react": patch | ||
| "@clerk/nextjs": patch | ||
| --- | ||
|
|
||
| Introduce functions that can be reused across front-end SDKs |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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,36 @@ | ||
| import type { InitialState, Resources } from '@clerk/types'; | ||
|
|
||
| import { deriveState } from '../deriveState'; | ||
|
|
||
| describe('deriveState', () => { | ||
| const mockInitialState = { | ||
| userId: 'user_2U330vGHg3llBga8Oi0fzzeNAaG', | ||
| sessionId: 'sess_2j1R7g3AUeKMx9M23dBO0XLEQGY', | ||
| orgId: 'org_2U330vGHg3llBga8Oi0fzzeNAaG', | ||
| } as InitialState; | ||
|
|
||
| const mockResources = { | ||
| client: {}, | ||
| user: { id: mockInitialState.userId }, | ||
| session: { id: mockInitialState.sessionId }, | ||
| organization: { id: mockInitialState.orgId }, | ||
| } as Resources; | ||
|
|
||
| it('uses SSR state when !clerkLoaded and initialState is provided', () => { | ||
| expect(deriveState(false, {} as Resources, mockInitialState)).toEqual(mockInitialState); | ||
| }); | ||
|
|
||
| it('uses CSR state when clerkLoaded', () => { | ||
| const result = deriveState(true, mockResources, undefined); | ||
| expect(result.userId).toBe(mockInitialState.userId); | ||
| expect(result.sessionId).toBe(mockInitialState.sessionId); | ||
| expect(result.orgId).toBe(mockInitialState.orgId); | ||
| }); | ||
|
|
||
| it('handles !clerkLoaded and undefined initialState', () => { | ||
| const result = deriveState(false, {} as Resources, undefined); | ||
| expect(result.userId).toBeUndefined(); | ||
| expect(result.sessionId).toBeUndefined(); | ||
| expect(result.orgId).toBeUndefined(); | ||
| }); | ||
| }); |
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.