-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(astro): Simplify submodules and drop
bundled
variant (#3701)
- Loading branch information
1 parent
0937bf6
commit 83eefc6
Showing
40 changed files
with
77 additions
and
170 deletions.
There are no files selected for viewing
This file contains 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,15 @@ | ||
--- | ||
"@clerk/astro": patch | ||
--- | ||
|
||
Simplify submodules and drop the `bunlded` variant. | ||
|
||
Moved | ||
- `@clerk/astro/client/react` to `@clerk/astro/react` | ||
- `@clerk/astro/client/stores` to `@clerk/astro/client` | ||
Dropped | ||
- `@clerk/astro/bundled` | ||
- `@clerk/astro/client/bundled` | ||
- `@clerk/astro/internal/bundled` | ||
- `@clerk/astro/integration` | ||
- `@clerk/astro/integration/bundled` |
2 changes: 1 addition & 1 deletion
2
integration/templates/astro-node/src/components/SignOutReact.tsx
This file contains 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
4 changes: 2 additions & 2 deletions
4
integration/templates/astro-node/src/components/page-with-user.tsx
This file contains 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 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 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 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
2 changes: 1 addition & 1 deletion
2
integration/templates/astro-node/src/pages/react/only-admins.astro
This file contains 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
2 changes: 1 addition & 1 deletion
2
integration/templates/astro-node/src/pages/react/only-members.astro
This file contains 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 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 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 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,3 @@ | ||
{ | ||
"main": "../../dist/react/index.js" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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,59 +1,2 @@ | ||
import { waitForClerkScript } from '../internal/utils/loadClerkJSScript'; | ||
import { $clerk, $csrState } from '../stores/internal'; | ||
import type { AstroClerkIntegrationParams, AstroClerkUpdateOptions } from '../types'; | ||
import { mountAllClerkAstroJSComponents } from './mount-clerk-astro-js-components'; | ||
import { runOnce } from './run-once'; | ||
|
||
let initOptions: AstroClerkIntegrationParams | undefined; | ||
|
||
/** | ||
* Prevents firing clerk.load multiple times | ||
*/ | ||
export const createClerkInstance = runOnce(createClerkInstanceInternal); | ||
|
||
export async function createClerkInstanceInternal(options?: AstroClerkIntegrationParams) { | ||
let clerkJSInstance = window.Clerk; | ||
if (!clerkJSInstance) { | ||
await waitForClerkScript(); | ||
|
||
if (!window.Clerk) { | ||
throw new Error('Failed to download latest ClerkJS. Contact [email protected].'); | ||
} | ||
clerkJSInstance = window.Clerk; | ||
} | ||
|
||
if (!$clerk.get()) { | ||
// @ts-ignore | ||
$clerk.set(clerkJSInstance); | ||
} | ||
|
||
initOptions = options; | ||
// TODO: Update Clerk type from @clerk/types to include this method | ||
return (clerkJSInstance as any) | ||
.load(options) | ||
.then(() => { | ||
$csrState.setKey('isLoaded', true); | ||
|
||
mountAllClerkAstroJSComponents(); | ||
|
||
clerkJSInstance.addListener(payload => { | ||
$csrState.setKey('client', payload.client); | ||
$csrState.setKey('user', payload.user); | ||
$csrState.setKey('session', payload.session); | ||
$csrState.setKey('organization', payload.organization); | ||
}); | ||
}) | ||
.catch(() => {}); | ||
} | ||
|
||
export function updateClerkOptions(options: AstroClerkUpdateOptions) { | ||
const clerk = $clerk.get(); | ||
if (!clerk) { | ||
throw new Error('Missing clerk instance'); | ||
} | ||
// TODO: Update Clerk type from @clerk/types to include this method | ||
void (clerk as any).__unstable__updateProps({ | ||
options: { ...initOptions, ...options }, | ||
appearance: { ...initOptions?.appearance, ...options.appearance }, | ||
}); | ||
} | ||
export { updateClerkOptions } from '../internal/create-clerk-instance'; | ||
export * from '../stores/external'; |
This file was deleted.
Oops, something went wrong.
This file contains 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 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 +1,3 @@ | ||
export { default } from './integration'; | ||
import { createIntegration } from './integration/create-integration'; | ||
|
||
export default createIntegration(); |
This file was deleted.
Oops, something went wrong.
This file contains 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 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,30 +1,35 @@ | ||
import { Clerk } from '@clerk/clerk-js'; | ||
|
||
import { waitForClerkScript } from '../internal/utils/loadClerkJSScript'; | ||
import { $clerk, $csrState } from '../stores/internal'; | ||
import type { AstroClerkCreateInstanceParams, AstroClerkUpdateOptions } from '../types'; | ||
import type { AstroClerkIntegrationParams, AstroClerkUpdateOptions } from '../types'; | ||
import { mountAllClerkAstroJSComponents } from './mount-clerk-astro-js-components'; | ||
import { runOnce } from './run-once'; | ||
import type { CreateClerkInstanceInternalFn } from './types'; | ||
|
||
let initOptions: AstroClerkCreateInstanceParams | undefined; | ||
let initOptions: AstroClerkIntegrationParams | undefined; | ||
|
||
/** | ||
* Prevents firing clerk.load multiple times | ||
*/ | ||
export const createClerkInstance: CreateClerkInstanceInternalFn = runOnce(createClerkInstanceInternal); | ||
const createClerkInstance = runOnce(createClerkInstanceInternal); | ||
|
||
export function createClerkInstanceInternal(options?: AstroClerkCreateInstanceParams) { | ||
let clerkJSInstance = window.Clerk as unknown as Clerk; | ||
async function createClerkInstanceInternal(options?: AstroClerkIntegrationParams) { | ||
let clerkJSInstance = window.Clerk; | ||
if (!clerkJSInstance) { | ||
clerkJSInstance = new Clerk(options!.publishableKey); | ||
await waitForClerkScript(); | ||
|
||
if (!window.Clerk) { | ||
throw new Error('Failed to download latest ClerkJS. Contact [email protected].'); | ||
} | ||
clerkJSInstance = window.Clerk; | ||
} | ||
|
||
if (!$clerk.get()) { | ||
// @ts-ignore | ||
$clerk.set(clerkJSInstance); | ||
// @ts-ignore | ||
window.Clerk = clerkJSInstance; | ||
} | ||
|
||
initOptions = options; | ||
return clerkJSInstance | ||
// TODO: Update Clerk type from @clerk/types to include this method | ||
return (clerkJSInstance as any) | ||
.load(options) | ||
.then(() => { | ||
$csrState.setKey('isLoaded', true); | ||
|
@@ -41,14 +46,16 @@ export function createClerkInstanceInternal(options?: AstroClerkCreateInstancePa | |
.catch(() => {}); | ||
} | ||
|
||
export function updateClerkOptions(options: AstroClerkUpdateOptions) { | ||
function updateClerkOptions(options: AstroClerkUpdateOptions) { | ||
const clerk = $clerk.get(); | ||
if (!clerk) { | ||
throw new Error('Missing clerk instance'); | ||
} | ||
//@ts-ignore | ||
clerk.__unstable__updateProps({ | ||
// TODO: Update Clerk type from @clerk/types to include this method | ||
void (clerk as any).__unstable__updateProps({ | ||
options: { ...initOptions, ...options }, | ||
appearance: { ...initOptions?.appearance, ...options.appearance }, | ||
}); | ||
} | ||
|
||
export { createClerkInstance, updateClerkOptions }; |
This file contains 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 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ro/src/client/react/controlComponents.tsx → ...ges/astro/src/react/controlComponents.tsx
This file contains 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 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.