From 65ab498a66d26921ccd4a8ce7484a3a7f499e0e1 Mon Sep 17 00:00:00 2001 From: panteliselef Date: Mon, 1 Jul 2024 14:47:34 +0300 Subject: [PATCH 01/23] feat(astro): Introduce Astro SDK --- .../control/ClerkLayout.astro | 7 +++ packages/astro/src/client/hotload.ts | 58 +++++++++++++++++++ packages/astro/src/hotload.ts | 1 + packages/astro/src/integration/hotload.ts | 5 ++ packages/astro/src/internal/hotload.ts | 13 +++++ packages/astro/src/stores/index.ts | 2 + packages/astro/src/v0/clerkClient.ts | 20 +++++++ packages/astro/src/v0/constants.ts | 55 ++++++++++++++++++ packages/astro/src/v0/index.ts | 2 + packages/astro/v0/package.json | 3 + 10 files changed, 166 insertions(+) create mode 100644 packages/astro/src/astro-components/control/ClerkLayout.astro create mode 100644 packages/astro/src/client/hotload.ts create mode 100644 packages/astro/src/hotload.ts create mode 100644 packages/astro/src/integration/hotload.ts create mode 100644 packages/astro/src/internal/hotload.ts create mode 100644 packages/astro/src/stores/index.ts create mode 100644 packages/astro/src/v0/clerkClient.ts create mode 100644 packages/astro/src/v0/constants.ts create mode 100644 packages/astro/src/v0/index.ts create mode 100644 packages/astro/v0/package.json diff --git a/packages/astro/src/astro-components/control/ClerkLayout.astro b/packages/astro/src/astro-components/control/ClerkLayout.astro new file mode 100644 index 00000000000..c4f4795eced --- /dev/null +++ b/packages/astro/src/astro-components/control/ClerkLayout.astro @@ -0,0 +1,7 @@ +--- +interface Props { + protectedPage?: boolean; +} + +--- + diff --git a/packages/astro/src/client/hotload.ts b/packages/astro/src/client/hotload.ts new file mode 100644 index 00000000000..57b8b853a63 --- /dev/null +++ b/packages/astro/src/client/hotload.ts @@ -0,0 +1,58 @@ +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 support@clerk.com.'); + } + clerkJSInstance = window.Clerk; + } + + if (!$clerk.get()) { + $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 }, + }); +} diff --git a/packages/astro/src/hotload.ts b/packages/astro/src/hotload.ts new file mode 100644 index 00000000000..91fef73a055 --- /dev/null +++ b/packages/astro/src/hotload.ts @@ -0,0 +1 @@ +export { default } from './integration/hotload'; diff --git a/packages/astro/src/integration/hotload.ts b/packages/astro/src/integration/hotload.ts new file mode 100644 index 00000000000..77f3eaaa6b7 --- /dev/null +++ b/packages/astro/src/integration/hotload.ts @@ -0,0 +1,5 @@ +import { createIntegration } from './create-integration'; + +export default createIntegration({ + mode: 'hotload', +}); diff --git a/packages/astro/src/internal/hotload.ts b/packages/astro/src/internal/hotload.ts new file mode 100644 index 00000000000..ca17cfb879f --- /dev/null +++ b/packages/astro/src/internal/hotload.ts @@ -0,0 +1,13 @@ +/** + * The following code will be used in order to be injected as script via the astro integration. + * F.e. + * + * injectScript('before-hydration', `...`) + */ + +import { createClerkInstance } from '../client/hotload'; +import { createInjectionScriptRunner } from './create-injection-script-runner'; + +const runInjectionScript = createInjectionScriptRunner(createClerkInstance); + +export { runInjectionScript }; diff --git a/packages/astro/src/stores/index.ts b/packages/astro/src/stores/index.ts new file mode 100644 index 00000000000..7e13c9380c8 --- /dev/null +++ b/packages/astro/src/stores/index.ts @@ -0,0 +1,2 @@ +// TODO: Don't expose internal +export * from './internal'; diff --git a/packages/astro/src/v0/clerkClient.ts b/packages/astro/src/v0/clerkClient.ts new file mode 100644 index 00000000000..b5b7320b560 --- /dev/null +++ b/packages/astro/src/v0/clerkClient.ts @@ -0,0 +1,20 @@ +import { createClerkClient } from '@clerk/backend'; +import { deprecated } from '@clerk/shared/deprecated'; + +import { API_URL, API_VERSION, SECRET_KEY } from './constants'; + +const clerkClientSingleton = createClerkClient({ secretKey: SECRET_KEY, apiVersion: API_VERSION, apiUrl: API_URL }); + +/** + * @deprecated + * Accessing `clerkClient` as a variable is deprecated and will be removed in a future release. Please use `clerkClient()` as a function instead. + */ +const clerkClient = new Proxy(clerkClientSingleton, { + get(target, prop, receiver) { + deprecated('clerkClient object', 'Use `clerkClient()` as a function instead.'); + + return Reflect.get(target, prop, receiver); + }, +}); + +export { clerkClient }; diff --git a/packages/astro/src/v0/constants.ts b/packages/astro/src/v0/constants.ts new file mode 100644 index 00000000000..d46797255a1 --- /dev/null +++ b/packages/astro/src/v0/constants.ts @@ -0,0 +1,55 @@ +const apiKey = import.meta.env.CLERK_API_KEY || ''; + +const secretKey = import.meta.env.CLERK_SECRET_KEY || ''; + +const apiVersion = import.meta.env.CLERK_API_VERSION || 'v1'; + +const apiUrl = import.meta.env.CLERK_API_URL || 'https://api.clerk.dev'; + +const frontendApi = import.meta.env.PUBLIC_ASTRO_APP_CLERK_FRONTEND_API || ''; + +const publishableKey = import.meta.env.PUBLIC_ASTRO_APP_CLERK_PUBLISHABLE_KEY || ''; + +const signInUrl = import.meta.env.PUBLIC_ASTRO_APP_CLERK_SIGN_IN_URL || ('' as string); + +const signUpUrl = import.meta.env.PUBLIC_ASTRO_APP_CLERK_SIGN_UP_URL || ('' as string); + +const jwtKey = import.meta.env.CLERK_JWT_KEY || ''; + +const PUBLISHABLE_KEY = publishableKey; +const SECRET_KEY = secretKey; +const SIGN_IN_URL = signInUrl; +const SIGN_UP_URL = signUpUrl; +const DOMAIN = import.meta.env.PUBLIC_ASTRO_APP_CLERK_DOMAIN || ('' as string); +const PROXY_URL = import.meta.env.PUBLIC_ASTRO_APP_CLERK_PROXY_URL || ('' as string); +const IS_SATELLITE = import.meta.env.PUBLIC_ASTRO_APP_CLERK_IS_SATELLITE === 'true'; +const API_VERSION = import.meta.env.CLERK_API_VERSION || 'v1'; +const API_URL = import.meta.env.CLERK_API_URL || 'https://api.clerk.dev'; + +const CLERK_JS_URL = import.meta.env.PUBLIC_ASTRO_APP_CLERK_JS_URL; +const CLERK_JS_VARIANT = import.meta.env.PUBLIC_ASTRO_APP_CLERK_JS_VARIANT; +const CLERK_JS_VERSION = import.meta.env.PUBLIC_ASTRO_APP_CLERK_JS_VERSION; + +export { + secretKey, + apiKey, + apiUrl, + apiVersion, + frontendApi, + publishableKey, + jwtKey, + signInUrl, + signUpUrl, + PUBLISHABLE_KEY, + SECRET_KEY, + SIGN_IN_URL, + SIGN_UP_URL, + DOMAIN, + PROXY_URL, + IS_SATELLITE, + API_URL, + API_VERSION, + CLERK_JS_URL, + CLERK_JS_VARIANT, + CLERK_JS_VERSION, +}; diff --git a/packages/astro/src/v0/index.ts b/packages/astro/src/v0/index.ts new file mode 100644 index 00000000000..454b8ea7992 --- /dev/null +++ b/packages/astro/src/v0/index.ts @@ -0,0 +1,2 @@ +export * from './clerkClient'; +export * from './constants'; diff --git a/packages/astro/v0/package.json b/packages/astro/v0/package.json new file mode 100644 index 00000000000..d2fdc59191a --- /dev/null +++ b/packages/astro/v0/package.json @@ -0,0 +1,3 @@ +{ + "main": "../dist/v0/index.js" +} From 52bb715a08e5f524a5510f7493a756fd3d1b7137 Mon Sep 17 00:00:00 2001 From: panteliselef Date: Mon, 1 Jul 2024 14:52:44 +0300 Subject: [PATCH 02/23] chore(astro): Cleanup --- .../astro/src/astro-components/control/ClerkLayout.astro | 7 ------- packages/astro/src/client/hotload.ts | 1 + 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 packages/astro/src/astro-components/control/ClerkLayout.astro diff --git a/packages/astro/src/astro-components/control/ClerkLayout.astro b/packages/astro/src/astro-components/control/ClerkLayout.astro deleted file mode 100644 index c4f4795eced..00000000000 --- a/packages/astro/src/astro-components/control/ClerkLayout.astro +++ /dev/null @@ -1,7 +0,0 @@ ---- -interface Props { - protectedPage?: boolean; -} - ---- - diff --git a/packages/astro/src/client/hotload.ts b/packages/astro/src/client/hotload.ts index 57b8b853a63..ffe5b8c612b 100644 --- a/packages/astro/src/client/hotload.ts +++ b/packages/astro/src/client/hotload.ts @@ -23,6 +23,7 @@ export async function createClerkInstanceInternal(options?: AstroClerkIntegratio } if (!$clerk.get()) { + // @ts-ignore $clerk.set(clerkJSInstance); } From f6ae5ae59b4cc9556b429c8f88676507db2627c0 Mon Sep 17 00:00:00 2001 From: panteliselef Date: Mon, 1 Jul 2024 15:30:31 +0300 Subject: [PATCH 03/23] chore(astro): Drop deprecations --- packages/astro/src/stores/index.ts | 2 - packages/astro/src/v0/clerkClient.ts | 20 ---------- packages/astro/src/v0/constants.ts | 55 ---------------------------- packages/astro/src/v0/index.ts | 2 - packages/astro/v0/package.json | 3 -- 5 files changed, 82 deletions(-) delete mode 100644 packages/astro/src/stores/index.ts delete mode 100644 packages/astro/src/v0/clerkClient.ts delete mode 100644 packages/astro/src/v0/constants.ts delete mode 100644 packages/astro/src/v0/index.ts delete mode 100644 packages/astro/v0/package.json diff --git a/packages/astro/src/stores/index.ts b/packages/astro/src/stores/index.ts deleted file mode 100644 index 7e13c9380c8..00000000000 --- a/packages/astro/src/stores/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -// TODO: Don't expose internal -export * from './internal'; diff --git a/packages/astro/src/v0/clerkClient.ts b/packages/astro/src/v0/clerkClient.ts deleted file mode 100644 index b5b7320b560..00000000000 --- a/packages/astro/src/v0/clerkClient.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { createClerkClient } from '@clerk/backend'; -import { deprecated } from '@clerk/shared/deprecated'; - -import { API_URL, API_VERSION, SECRET_KEY } from './constants'; - -const clerkClientSingleton = createClerkClient({ secretKey: SECRET_KEY, apiVersion: API_VERSION, apiUrl: API_URL }); - -/** - * @deprecated - * Accessing `clerkClient` as a variable is deprecated and will be removed in a future release. Please use `clerkClient()` as a function instead. - */ -const clerkClient = new Proxy(clerkClientSingleton, { - get(target, prop, receiver) { - deprecated('clerkClient object', 'Use `clerkClient()` as a function instead.'); - - return Reflect.get(target, prop, receiver); - }, -}); - -export { clerkClient }; diff --git a/packages/astro/src/v0/constants.ts b/packages/astro/src/v0/constants.ts deleted file mode 100644 index d46797255a1..00000000000 --- a/packages/astro/src/v0/constants.ts +++ /dev/null @@ -1,55 +0,0 @@ -const apiKey = import.meta.env.CLERK_API_KEY || ''; - -const secretKey = import.meta.env.CLERK_SECRET_KEY || ''; - -const apiVersion = import.meta.env.CLERK_API_VERSION || 'v1'; - -const apiUrl = import.meta.env.CLERK_API_URL || 'https://api.clerk.dev'; - -const frontendApi = import.meta.env.PUBLIC_ASTRO_APP_CLERK_FRONTEND_API || ''; - -const publishableKey = import.meta.env.PUBLIC_ASTRO_APP_CLERK_PUBLISHABLE_KEY || ''; - -const signInUrl = import.meta.env.PUBLIC_ASTRO_APP_CLERK_SIGN_IN_URL || ('' as string); - -const signUpUrl = import.meta.env.PUBLIC_ASTRO_APP_CLERK_SIGN_UP_URL || ('' as string); - -const jwtKey = import.meta.env.CLERK_JWT_KEY || ''; - -const PUBLISHABLE_KEY = publishableKey; -const SECRET_KEY = secretKey; -const SIGN_IN_URL = signInUrl; -const SIGN_UP_URL = signUpUrl; -const DOMAIN = import.meta.env.PUBLIC_ASTRO_APP_CLERK_DOMAIN || ('' as string); -const PROXY_URL = import.meta.env.PUBLIC_ASTRO_APP_CLERK_PROXY_URL || ('' as string); -const IS_SATELLITE = import.meta.env.PUBLIC_ASTRO_APP_CLERK_IS_SATELLITE === 'true'; -const API_VERSION = import.meta.env.CLERK_API_VERSION || 'v1'; -const API_URL = import.meta.env.CLERK_API_URL || 'https://api.clerk.dev'; - -const CLERK_JS_URL = import.meta.env.PUBLIC_ASTRO_APP_CLERK_JS_URL; -const CLERK_JS_VARIANT = import.meta.env.PUBLIC_ASTRO_APP_CLERK_JS_VARIANT; -const CLERK_JS_VERSION = import.meta.env.PUBLIC_ASTRO_APP_CLERK_JS_VERSION; - -export { - secretKey, - apiKey, - apiUrl, - apiVersion, - frontendApi, - publishableKey, - jwtKey, - signInUrl, - signUpUrl, - PUBLISHABLE_KEY, - SECRET_KEY, - SIGN_IN_URL, - SIGN_UP_URL, - DOMAIN, - PROXY_URL, - IS_SATELLITE, - API_URL, - API_VERSION, - CLERK_JS_URL, - CLERK_JS_VARIANT, - CLERK_JS_VERSION, -}; diff --git a/packages/astro/src/v0/index.ts b/packages/astro/src/v0/index.ts deleted file mode 100644 index 454b8ea7992..00000000000 --- a/packages/astro/src/v0/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './clerkClient'; -export * from './constants'; diff --git a/packages/astro/v0/package.json b/packages/astro/v0/package.json deleted file mode 100644 index d2fdc59191a..00000000000 --- a/packages/astro/v0/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "../dist/v0/index.js" -} From 0421dd0b88ec722d4352e865361ca86fa9f33c12 Mon Sep 17 00:00:00 2001 From: panteliselef Date: Mon, 1 Jul 2024 15:57:53 +0300 Subject: [PATCH 04/23] chore(astro): Make hotloading the default --- packages/astro/src/client/hotload.ts | 59 ----------------------- packages/astro/src/hotload.ts | 1 - packages/astro/src/integration/hotload.ts | 5 -- packages/astro/src/internal/hotload.ts | 13 ----- 4 files changed, 78 deletions(-) delete mode 100644 packages/astro/src/client/hotload.ts delete mode 100644 packages/astro/src/hotload.ts delete mode 100644 packages/astro/src/integration/hotload.ts delete mode 100644 packages/astro/src/internal/hotload.ts diff --git a/packages/astro/src/client/hotload.ts b/packages/astro/src/client/hotload.ts deleted file mode 100644 index ffe5b8c612b..00000000000 --- a/packages/astro/src/client/hotload.ts +++ /dev/null @@ -1,59 +0,0 @@ -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 support@clerk.com.'); - } - 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 }, - }); -} diff --git a/packages/astro/src/hotload.ts b/packages/astro/src/hotload.ts deleted file mode 100644 index 91fef73a055..00000000000 --- a/packages/astro/src/hotload.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './integration/hotload'; diff --git a/packages/astro/src/integration/hotload.ts b/packages/astro/src/integration/hotload.ts deleted file mode 100644 index 77f3eaaa6b7..00000000000 --- a/packages/astro/src/integration/hotload.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { createIntegration } from './create-integration'; - -export default createIntegration({ - mode: 'hotload', -}); diff --git a/packages/astro/src/internal/hotload.ts b/packages/astro/src/internal/hotload.ts deleted file mode 100644 index ca17cfb879f..00000000000 --- a/packages/astro/src/internal/hotload.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * The following code will be used in order to be injected as script via the astro integration. - * F.e. - * - * injectScript('before-hydration', `...`) - */ - -import { createClerkInstance } from '../client/hotload'; -import { createInjectionScriptRunner } from './create-injection-script-runner'; - -const runInjectionScript = createInjectionScriptRunner(createClerkInstance); - -export { runInjectionScript }; From 3f6b158f5f81fc121de4051e082ed231a4900e56 Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Tue, 2 Jul 2024 12:42:50 -0700 Subject: [PATCH 05/23] chore(astro): add react unstyled components --- .../astro-components/react/SignInButton.astro | 15 +++++ .../react/SignOutButton.astro | 15 +++++ .../astro-components/react/SignUpButton.astro | 15 +++++ .../astro/src/astro-components/react/index.ts | 6 ++ .../astro/src/client/react/SignInButton.tsx | 46 +++++++++++++++ .../astro/src/client/react/SignOutButton.tsx | 30 ++++++++++ .../astro/src/client/react/SignUpButton.tsx | 56 +++++++++++++++++++ packages/astro/src/client/react/index.ts | 7 +++ packages/astro/src/client/react/types.ts | 20 +++++++ packages/astro/src/client/react/utils.tsx | 28 ++++++++++ 10 files changed, 238 insertions(+) create mode 100644 packages/astro/src/astro-components/react/SignInButton.astro create mode 100644 packages/astro/src/astro-components/react/SignOutButton.astro create mode 100644 packages/astro/src/astro-components/react/SignUpButton.astro create mode 100644 packages/astro/src/client/react/SignInButton.tsx create mode 100644 packages/astro/src/client/react/SignOutButton.tsx create mode 100644 packages/astro/src/client/react/SignUpButton.tsx create mode 100644 packages/astro/src/client/react/types.ts diff --git a/packages/astro/src/astro-components/react/SignInButton.astro b/packages/astro/src/astro-components/react/SignInButton.astro new file mode 100644 index 00000000000..b87315d4b07 --- /dev/null +++ b/packages/astro/src/astro-components/react/SignInButton.astro @@ -0,0 +1,15 @@ +--- +import type { SignInButtonProps } from "@clerk/astro/client/react"; +type Props = SignInButtonProps + +import { SignInButton as SignInButtonReact } from "@clerk/astro/client/react"; + +const props = { + ...Astro.props +} +--- + + diff --git a/packages/astro/src/astro-components/react/SignOutButton.astro b/packages/astro/src/astro-components/react/SignOutButton.astro new file mode 100644 index 00000000000..3b4602684cb --- /dev/null +++ b/packages/astro/src/astro-components/react/SignOutButton.astro @@ -0,0 +1,15 @@ +--- +import type { SignOutButtonProps } from "@clerk/astro/client/react"; +type Props = SignOutButtonProps + +import { SignOutButton as SignOutButtonReact } from "@clerk/astro/client/react"; + +const props = { + ...Astro.props +} +--- + + diff --git a/packages/astro/src/astro-components/react/SignUpButton.astro b/packages/astro/src/astro-components/react/SignUpButton.astro new file mode 100644 index 00000000000..01870f3d964 --- /dev/null +++ b/packages/astro/src/astro-components/react/SignUpButton.astro @@ -0,0 +1,15 @@ +--- +import type { SignUpButtonProps } from "@clerk/astro/client/react"; +type Props = SignUpButtonProps + +import { SignUpButton as SignUpButtonReact } from "@clerk/astro/client/react"; + +const props = { + ...Astro.props +} +--- + + diff --git a/packages/astro/src/astro-components/react/index.ts b/packages/astro/src/astro-components/react/index.ts index 425d016df1e..e2d7f9525fa 100644 --- a/packages/astro/src/astro-components/react/index.ts +++ b/packages/astro/src/astro-components/react/index.ts @@ -20,3 +20,9 @@ export { default as SignedIn } from './SignedIn.astro'; export { default as SignedOut } from './SignedOut.astro'; // @ts-ignore export { default as Protect } from './Protect.astro'; +// @ts-ignore +export { default as SignInButton } from './SignInButton.astro'; +// @ts-ignore +export { default as SignOutButton } from './SignOutButton.astro'; +// @ts-ignore +export { default as SignUpButton } from './SignUpButton.astro'; diff --git a/packages/astro/src/client/react/SignInButton.tsx b/packages/astro/src/client/react/SignInButton.tsx new file mode 100644 index 00000000000..d519108efc0 --- /dev/null +++ b/packages/astro/src/client/react/SignInButton.tsx @@ -0,0 +1,46 @@ +import type { SignInProps } from '@clerk/types'; +import React from 'react'; + +import type { SignInButtonProps } from './types'; +import { assertSingleChild, normalizeWithDefaultValue, safeExecute, withClerk, type WithClerkProp } from './utils'; + +export type { SignInButtonProps }; + +export const SignInButton = withClerk(({ clerk, children, ...props }: WithClerkProp) => { + const { signUpFallbackRedirectUrl, forceRedirectUrl, fallbackRedirectUrl, signUpForceRedirectUrl, mode, ...rest } = + props; + children = normalizeWithDefaultValue(children, 'Sign in'); + const child = assertSingleChild(children)('SignInButton'); + + const clickHandler = () => { + const opts: SignInProps = { + forceRedirectUrl, + fallbackRedirectUrl, + signUpFallbackRedirectUrl, + signUpForceRedirectUrl, + }; + + if (!clerk) { + return; + } + + if (mode === 'modal') { + return clerk.openSignIn(opts); + } + return clerk.redirectToSignIn({ + ...opts, + signInFallbackRedirectUrl: fallbackRedirectUrl, + signInForceRedirectUrl: forceRedirectUrl, + }); + }; + + const wrappedChildClickHandler: React.MouseEventHandler = async e => { + if (child && typeof child === 'object' && 'props' in child) { + await safeExecute(child.props.onClick)(e); + } + return clickHandler(); + }; + + const childProps = { ...rest, onClick: wrappedChildClickHandler }; + return React.cloneElement(child as React.ReactElement, childProps); +}, 'SignInButton'); diff --git a/packages/astro/src/client/react/SignOutButton.tsx b/packages/astro/src/client/react/SignOutButton.tsx new file mode 100644 index 00000000000..863db62bdf9 --- /dev/null +++ b/packages/astro/src/client/react/SignOutButton.tsx @@ -0,0 +1,30 @@ +import type { SignOutOptions } from '@clerk/types'; +import React from 'react'; + +import type { WithClerkProp } from './utils'; +import { assertSingleChild, normalizeWithDefaultValue, safeExecute, withClerk } from './utils'; + +export type SignOutButtonProps = { + redirectUrl?: string; + signOutOptions?: SignOutOptions; + children?: React.ReactNode; +}; + +export const SignOutButton = withClerk( + ({ clerk, children, ...props }: React.PropsWithChildren>) => { + const { redirectUrl = '/', signOutOptions, ...rest } = props; + + children = normalizeWithDefaultValue(children, 'Sign out'); + const child = assertSingleChild(children)('SignOutButton'); + + const clickHandler = () => clerk?.signOut({ redirectUrl }); + const wrappedChildClickHandler: React.MouseEventHandler = async e => { + await safeExecute(child.props.onClick)(e); + return clickHandler(); + }; + + const childProps = { ...rest, onClick: wrappedChildClickHandler }; + return React.cloneElement(child as React.ReactElement, childProps); + }, + 'SignOutButton', +); diff --git a/packages/astro/src/client/react/SignUpButton.tsx b/packages/astro/src/client/react/SignUpButton.tsx new file mode 100644 index 00000000000..b37651e5609 --- /dev/null +++ b/packages/astro/src/client/react/SignUpButton.tsx @@ -0,0 +1,56 @@ +import type { SignUpProps } from '@clerk/types'; +import React from 'react'; + +import type { SignUpButtonProps } from './types'; +import { assertSingleChild, normalizeWithDefaultValue, safeExecute, withClerk, type WithClerkProp } from './utils'; + +export type { SignUpButtonProps }; + +export const SignUpButton = withClerk(({ clerk, children, ...props }: WithClerkProp) => { + const { + fallbackRedirectUrl, + forceRedirectUrl, + signInFallbackRedirectUrl, + signInForceRedirectUrl, + mode, + unsafeMetadata, + ...rest + } = props; + + children = normalizeWithDefaultValue(children, 'Sign up'); + const child = assertSingleChild(children)('SignUpButton'); + + const clickHandler = () => { + const opts: SignUpProps = { + fallbackRedirectUrl, + forceRedirectUrl, + signInFallbackRedirectUrl, + signInForceRedirectUrl, + unsafeMetadata, + }; + + if (!clerk) { + return; + } + + if (mode === 'modal') { + return clerk.openSignUp(opts); + } + + return clerk.redirectToSignUp({ + ...opts, + signUpFallbackRedirectUrl: fallbackRedirectUrl, + signUpForceRedirectUrl: forceRedirectUrl, + }); + }; + + const wrappedChildClickHandler: React.MouseEventHandler = async e => { + if (child && typeof child === 'object' && 'props' in child) { + await safeExecute(child.props.onClick)(e); + } + return clickHandler(); + }; + + const childProps = { ...rest, onClick: wrappedChildClickHandler }; + return React.cloneElement(child as React.ReactElement, childProps); +}, 'SignUpButton'); diff --git a/packages/astro/src/client/react/index.ts b/packages/astro/src/client/react/index.ts index fca69ad5a18..9b8cbf229f4 100644 --- a/packages/astro/src/client/react/index.ts +++ b/packages/astro/src/client/react/index.ts @@ -1,3 +1,10 @@ +import { SignInButton, type SignInButtonProps } from './SignInButton'; +import { SignOutButton, type SignOutButtonProps } from './SignOutButton'; +import { SignUpButton, type SignUpButtonProps } from './SignUpButton'; + export * from './uiComponents'; export * from './controlComponents'; export * from './hooks'; +export { SignInButton, SignOutButton, SignUpButton }; + +export type { SignInButtonProps, SignOutButtonProps, SignUpButtonProps }; diff --git a/packages/astro/src/client/react/types.ts b/packages/astro/src/client/react/types.ts new file mode 100644 index 00000000000..04e11a5a3b6 --- /dev/null +++ b/packages/astro/src/client/react/types.ts @@ -0,0 +1,20 @@ +import type { SignInProps, SignUpProps } from '@clerk/types'; + +type ButtonProps = { + mode?: 'redirect' | 'modal'; + children?: React.ReactNode; +}; + +export type SignInButtonProps = ButtonProps & + Pick< + SignInProps, + 'fallbackRedirectUrl' | 'forceRedirectUrl' | 'signUpForceRedirectUrl' | 'signUpFallbackRedirectUrl' + >; + +export type SignUpButtonProps = { + unsafeMetadata?: SignUpUnsafeMetadata; +} & ButtonProps & + Pick< + SignUpProps, + 'fallbackRedirectUrl' | 'forceRedirectUrl' | 'signInForceRedirectUrl' | 'signInFallbackRedirectUrl' + >; diff --git a/packages/astro/src/client/react/utils.tsx b/packages/astro/src/client/react/utils.tsx index 4842c113c30..789969b9c44 100644 --- a/packages/astro/src/client/react/utils.tsx +++ b/packages/astro/src/client/react/utils.tsx @@ -37,3 +37,31 @@ export const withClerk =

( export type WithClerkProp = T & { clerk: LoadedClerk | undefined | null; }; + +export const assertSingleChild = + (children: React.ReactNode) => + (name: 'SignInButton' | 'SignUpButton' | 'SignOutButton' | 'SignInWithMetamaskButton') => { + try { + return React.Children.only(children); + } catch (e) { + return `You've passed multiple children components to <${name}/>. You can only pass a single child component or text.`; + } + }; + +export const normalizeWithDefaultValue = (children: React.ReactNode | undefined, defaultText: string) => { + if (!children) { + children = defaultText; + } + if (typeof children === 'string') { + children = ; + } + return children; +}; + +export const safeExecute = + (cb: unknown) => + (...args: any) => { + if (cb && typeof cb === 'function') { + return cb(...args); + } + }; From 2e0aa4fb4fa7a7f7fc86254416258dea9ff859d9 Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Tue, 2 Jul 2024 13:49:40 -0700 Subject: [PATCH 06/23] chore(astro): add astro unstyled components --- packages/astro/package.json | 2 + .../unstyled/SignInButton.astro | 48 ++++++++++++++++++ .../unstyled/SignOutButton.astro | 24 +++++++++ .../unstyled/SignUpButton.astro | 50 +++++++++++++++++++ .../src/astro-components/unstyled/index.ts | 8 +++ 5 files changed, 132 insertions(+) create mode 100644 packages/astro/src/astro-components/unstyled/SignInButton.astro create mode 100644 packages/astro/src/astro-components/unstyled/SignOutButton.astro create mode 100644 packages/astro/src/astro-components/unstyled/SignUpButton.astro create mode 100644 packages/astro/src/astro-components/unstyled/index.ts diff --git a/packages/astro/package.json b/packages/astro/package.json index d823b33004d..4f2197f6e71 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -97,6 +97,8 @@ "./components/react/*": "./components/react/*", "./components/interactive": "./components/interactive/index.ts", "./components/interactive/*": "./components/interactive/*", + "./components/unstyled": "./components/unstyled/index.ts", + "./components/unstyled/*": "./components/unstyled/*", "./components/*": "./components/*", "./package.json": "./package.json" }, diff --git a/packages/astro/src/astro-components/unstyled/SignInButton.astro b/packages/astro/src/astro-components/unstyled/SignInButton.astro new file mode 100644 index 00000000000..8440110e0f8 --- /dev/null +++ b/packages/astro/src/astro-components/unstyled/SignInButton.astro @@ -0,0 +1,48 @@ +--- +import type { HTMLTag, Polymorphic } from 'astro/types' +import type { SignInProps } from "@clerk/types"; +type Props = Polymorphic + +import { customAlphabet, urlAlphabet } from "nanoid"; + +const safeId = customAlphabet(urlAlphabet, 10)(); + +const { as: Element = 'button', id = safeId, ...props } = Astro.props +--- + + + + + + diff --git a/packages/astro/src/astro-components/unstyled/SignOutButton.astro b/packages/astro/src/astro-components/unstyled/SignOutButton.astro new file mode 100644 index 00000000000..8e2463e7970 --- /dev/null +++ b/packages/astro/src/astro-components/unstyled/SignOutButton.astro @@ -0,0 +1,24 @@ +--- +import type { HTMLTag, Polymorphic } from 'astro/types' +type Props = Polymorphic<{ as: Tag; id?: string; mode?: 'redirect' | 'modal' }> + +import { customAlphabet, urlAlphabet } from "nanoid"; + +const safeId = customAlphabet(urlAlphabet, 10)(); + +const { as: Element = 'button', id = safeId, ...props } = Astro.props +--- + + + + + + diff --git a/packages/astro/src/astro-components/unstyled/SignUpButton.astro b/packages/astro/src/astro-components/unstyled/SignUpButton.astro new file mode 100644 index 00000000000..f8c73aa42e9 --- /dev/null +++ b/packages/astro/src/astro-components/unstyled/SignUpButton.astro @@ -0,0 +1,50 @@ +--- +import type { HTMLTag, Polymorphic } from 'astro/types' +import type { SignUpProps } from "@clerk/types"; +type Props = Polymorphic + +import { customAlphabet, urlAlphabet } from "nanoid"; + +const safeId = customAlphabet(urlAlphabet, 10)(); + +const { as: Element = 'button', id = safeId, ...props } = Astro.props +--- + + + + + + diff --git a/packages/astro/src/astro-components/unstyled/index.ts b/packages/astro/src/astro-components/unstyled/index.ts new file mode 100644 index 00000000000..d62e09924be --- /dev/null +++ b/packages/astro/src/astro-components/unstyled/index.ts @@ -0,0 +1,8 @@ +// The `ts-ignore` comments here are necessary because we're importing this file inside the `astro:components` +// virtual module's types, which means that `tsc` will try to resolve these imports. Don't mind the editor errors. +// @ts-ignore +export { default as SignInButton } from './SignInButton.astro'; +// @ts-ignore +export { default as SignUpButton } from './SignUpButton.astro'; +// @ts-ignore +export { default as SignOutButton } from './SignOutButton.astro'; From 82226fd1ed7e059d6043aae46e08d25eba5da951 Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Tue, 2 Jul 2024 14:11:29 -0700 Subject: [PATCH 07/23] chore(astro): fix typescript error in signout click handler --- packages/astro/src/client/react/SignOutButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/client/react/SignOutButton.tsx b/packages/astro/src/client/react/SignOutButton.tsx index 863db62bdf9..ce9728a62d5 100644 --- a/packages/astro/src/client/react/SignOutButton.tsx +++ b/packages/astro/src/client/react/SignOutButton.tsx @@ -19,7 +19,7 @@ export const SignOutButton = withClerk( const clickHandler = () => clerk?.signOut({ redirectUrl }); const wrappedChildClickHandler: React.MouseEventHandler = async e => { - await safeExecute(child.props.onClick)(e); + await safeExecute((child as any).props.onClick)(e); return clickHandler(); }; From 243f02343b885be178cc5809751d3daf1ec8ff33 Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Tue, 2 Jul 2024 14:14:17 -0700 Subject: [PATCH 08/23] chore(astro): update polymorphic element name for clarity --- .../astro/src/astro-components/unstyled/SignInButton.astro | 6 +++--- .../astro/src/astro-components/unstyled/SignOutButton.astro | 6 +++--- .../astro/src/astro-components/unstyled/SignUpButton.astro | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/astro/src/astro-components/unstyled/SignInButton.astro b/packages/astro/src/astro-components/unstyled/SignInButton.astro index 8440110e0f8..5fb2c596423 100644 --- a/packages/astro/src/astro-components/unstyled/SignInButton.astro +++ b/packages/astro/src/astro-components/unstyled/SignInButton.astro @@ -7,12 +7,12 @@ import { customAlphabet, urlAlphabet } from "nanoid"; const safeId = customAlphabet(urlAlphabet, 10)(); -const { as: Element = 'button', id = safeId, ...props } = Astro.props +const { as: Tag = 'button', id = safeId, ...props } = Astro.props --- - + - + diff --git a/packages/astro/src/astro-components/unstyled/SignOutButton.astro b/packages/astro/src/astro-components/unstyled/SignOutButton.astro index acf39490d3b..fc2e945bb71 100644 --- a/packages/astro/src/astro-components/unstyled/SignOutButton.astro +++ b/packages/astro/src/astro-components/unstyled/SignOutButton.astro @@ -1,6 +1,6 @@ --- import type { HTMLTag, Polymorphic } from 'astro/types' -type Props = Polymorphic<{ as: Tag; id?: string; mode?: 'redirect' | 'modal' }> +type Props = Polymorphic<{ as: Tag; id?: string; }> import { customAlphabet, urlAlphabet } from "nanoid"; @@ -9,20 +9,19 @@ const safeId = customAlphabet(urlAlphabet, 10)(); const { as: Tag = 'button', id = safeId, - ...props + redirectUrl, + ...elementProps } = Astro.props --- - + - diff --git a/packages/astro/src/astro-components/unstyled/SignUpButton.astro b/packages/astro/src/astro-components/unstyled/SignUpButton.astro index 6d29a98cacf..765a312d352 100644 --- a/packages/astro/src/astro-components/unstyled/SignUpButton.astro +++ b/packages/astro/src/astro-components/unstyled/SignUpButton.astro @@ -10,45 +10,42 @@ const safeId = customAlphabet(urlAlphabet, 10)(); const { as: Tag = 'button', id = safeId, - ...props + fallbackRedirectUrl, + forceRedirectUrl, + signInFallbackRedirectUrl, + signInForceRedirectUrl, + mode, + unsafeMetadata, + ...elementProps } = Astro.props + +const signUpOptions = { + fallbackRedirectUrl, + forceRedirectUrl, + signInFallbackRedirectUrl, + signInForceRedirectUrl, + unsafeMetadata, +} --- - + - From 9809f1db3e688004865a9c683eb98782593133af Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Thu, 4 Jul 2024 08:56:05 -0700 Subject: [PATCH 11/23] chore(astro): add missing redirectUrl prop type --- .../astro/src/astro-components/unstyled/SignOutButton.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/astro-components/unstyled/SignOutButton.astro b/packages/astro/src/astro-components/unstyled/SignOutButton.astro index fc2e945bb71..4d90de4b97c 100644 --- a/packages/astro/src/astro-components/unstyled/SignOutButton.astro +++ b/packages/astro/src/astro-components/unstyled/SignOutButton.astro @@ -1,6 +1,6 @@ --- import type { HTMLTag, Polymorphic } from 'astro/types' -type Props = Polymorphic<{ as: Tag; id?: string; }> +type Props = Polymorphic<{ as: Tag; id?: string; redirectUrl?: string }> import { customAlphabet, urlAlphabet } from "nanoid"; From 2a79d56f131e9b4d39afc7651c07485b7935d2d3 Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Thu, 4 Jul 2024 10:21:22 -0700 Subject: [PATCH 12/23] chore(astro): add default slot content --- packages/astro/src/astro-components/unstyled/SignInButton.astro | 2 +- .../astro/src/astro-components/unstyled/SignOutButton.astro | 2 +- packages/astro/src/astro-components/unstyled/SignUpButton.astro | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/astro/src/astro-components/unstyled/SignInButton.astro b/packages/astro/src/astro-components/unstyled/SignInButton.astro index 3bcecd7650b..61c5132b9ef 100644 --- a/packages/astro/src/astro-components/unstyled/SignInButton.astro +++ b/packages/astro/src/astro-components/unstyled/SignInButton.astro @@ -27,7 +27,7 @@ const signInOptions = { --- - + Sign in \n`, + ); + const clerkSafeEnvVariables = encoder.encode( + `\n`, + ); + const hotloadScript = encoder.encode(buildClerkHotloadScript(locals)); + + const stream = res.body!.pipeThrough( + new TransformStream({ + transform(chunk, controller) { + const index = findClosingHeadTagIndex(chunk, closingHeadTag); + const isClosingHeadTagFound = index !== -1; /** * Hijack html response to position `__CLERK_ASTRO_DATA__` before the closing `head` html tag */ - if (decodedValue.includes('')) { - const [p1, p2] = decodedValue.split(''); - controller.enqueue(encoder.encode(p1)); - controller.enqueue( - encoder.encode( - `\n`, - ), - ); - - controller.enqueue( - encoder.encode( - `\n`, - ), - ); + if (isClosingHeadTagFound) { + controller.enqueue(chunk.slice(0, index)); + controller.enqueue(clerkAstroData); + controller.enqueue(clerkSafeEnvVariables); if (__HOTLOAD__) { - controller.enqueue(encoder.encode(buildClerkHotloadScript(locals))); + controller.enqueue(hotloadScript); } - controller.enqueue(encoder.encode('')); - controller.enqueue(encoder.encode(p2)); + controller.enqueue(closingHeadTag); + controller.enqueue(chunk.slice(index + closingHeadTag.length)); } else { - controller.enqueue(value); + controller.enqueue(chunk); } - - ({ value, done } = await reader!.read()); - } - controller.close(); - }, - }); + }, + }), + ); const modifiedResponse = new Response(stream, { status: res.status, From 380c32912948bbe9fe91ef071c25e163d92dc073 Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Tue, 9 Jul 2024 09:46:41 -0700 Subject: [PATCH 21/23] chore(astro): Add session id prop to sign out button --- .../src/astro-components/unstyled/SignOutButton.astro | 10 ++++++---- packages/astro/src/client/react/SignOutButton.tsx | 10 ++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/astro/src/astro-components/unstyled/SignOutButton.astro b/packages/astro/src/astro-components/unstyled/SignOutButton.astro index 97f1996c1ac..13242cb0ee2 100644 --- a/packages/astro/src/astro-components/unstyled/SignOutButton.astro +++ b/packages/astro/src/astro-components/unstyled/SignOutButton.astro @@ -1,6 +1,7 @@ --- import type { HTMLTag, Polymorphic } from 'astro/types' -type Props = Polymorphic<{ as: Tag; redirectUrl?: string }> +import type { SignOutOptions } from '@clerk/types'; +type Props = Polymorphic<{ as: Tag; } & SignOutOptions> import { customAlphabet, urlAlphabet } from "nanoid"; @@ -8,7 +9,8 @@ const safeId = customAlphabet(urlAlphabet, 10)(); const { as: Tag = 'button', - redirectUrl, + redirectUrl = '/', + sessionId, ...elementProps } = Astro.props --- @@ -17,10 +19,10 @@ const { Sign out - diff --git a/packages/astro/src/client/react/SignOutButton.tsx b/packages/astro/src/client/react/SignOutButton.tsx index ce9728a62d5..c61a3eb527b 100644 --- a/packages/astro/src/client/react/SignOutButton.tsx +++ b/packages/astro/src/client/react/SignOutButton.tsx @@ -4,22 +4,20 @@ import React from 'react'; import type { WithClerkProp } from './utils'; import { assertSingleChild, normalizeWithDefaultValue, safeExecute, withClerk } from './utils'; -export type SignOutButtonProps = { - redirectUrl?: string; - signOutOptions?: SignOutOptions; +export type SignOutButtonProps = SignOutOptions & { children?: React.ReactNode; }; export const SignOutButton = withClerk( ({ clerk, children, ...props }: React.PropsWithChildren>) => { - const { redirectUrl = '/', signOutOptions, ...rest } = props; + const { redirectUrl = '/', sessionId, ...rest } = props; children = normalizeWithDefaultValue(children, 'Sign out'); const child = assertSingleChild(children)('SignOutButton'); - const clickHandler = () => clerk?.signOut({ redirectUrl }); + const clickHandler = () => clerk?.signOut({ redirectUrl, sessionId }); const wrappedChildClickHandler: React.MouseEventHandler = async e => { - await safeExecute((child as any).props.onClick)(e); + await safeExecute(child.props.onClick)(e); return clickHandler(); }; From 61db931d7d00a1479490c55bbb59f4c106338ec6 Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Tue, 9 Jul 2024 10:52:17 -0700 Subject: [PATCH 22/23] chore(astro): Remove wrapped unstyled react components --- .../src/astro-components/react/SignInButton.astro | 15 --------------- .../astro-components/react/SignOutButton.astro | 15 --------------- .../src/astro-components/react/SignUpButton.astro | 15 --------------- .../astro/src/astro-components/react/index.ts | 6 ------ 4 files changed, 51 deletions(-) delete mode 100644 packages/astro/src/astro-components/react/SignInButton.astro delete mode 100644 packages/astro/src/astro-components/react/SignOutButton.astro delete mode 100644 packages/astro/src/astro-components/react/SignUpButton.astro diff --git a/packages/astro/src/astro-components/react/SignInButton.astro b/packages/astro/src/astro-components/react/SignInButton.astro deleted file mode 100644 index b87315d4b07..00000000000 --- a/packages/astro/src/astro-components/react/SignInButton.astro +++ /dev/null @@ -1,15 +0,0 @@ ---- -import type { SignInButtonProps } from "@clerk/astro/client/react"; -type Props = SignInButtonProps - -import { SignInButton as SignInButtonReact } from "@clerk/astro/client/react"; - -const props = { - ...Astro.props -} ---- - - diff --git a/packages/astro/src/astro-components/react/SignOutButton.astro b/packages/astro/src/astro-components/react/SignOutButton.astro deleted file mode 100644 index 3b4602684cb..00000000000 --- a/packages/astro/src/astro-components/react/SignOutButton.astro +++ /dev/null @@ -1,15 +0,0 @@ ---- -import type { SignOutButtonProps } from "@clerk/astro/client/react"; -type Props = SignOutButtonProps - -import { SignOutButton as SignOutButtonReact } from "@clerk/astro/client/react"; - -const props = { - ...Astro.props -} ---- - - diff --git a/packages/astro/src/astro-components/react/SignUpButton.astro b/packages/astro/src/astro-components/react/SignUpButton.astro deleted file mode 100644 index 01870f3d964..00000000000 --- a/packages/astro/src/astro-components/react/SignUpButton.astro +++ /dev/null @@ -1,15 +0,0 @@ ---- -import type { SignUpButtonProps } from "@clerk/astro/client/react"; -type Props = SignUpButtonProps - -import { SignUpButton as SignUpButtonReact } from "@clerk/astro/client/react"; - -const props = { - ...Astro.props -} ---- - - diff --git a/packages/astro/src/astro-components/react/index.ts b/packages/astro/src/astro-components/react/index.ts index e2d7f9525fa..425d016df1e 100644 --- a/packages/astro/src/astro-components/react/index.ts +++ b/packages/astro/src/astro-components/react/index.ts @@ -20,9 +20,3 @@ export { default as SignedIn } from './SignedIn.astro'; export { default as SignedOut } from './SignedOut.astro'; // @ts-ignore export { default as Protect } from './Protect.astro'; -// @ts-ignore -export { default as SignInButton } from './SignInButton.astro'; -// @ts-ignore -export { default as SignOutButton } from './SignOutButton.astro'; -// @ts-ignore -export { default as SignUpButton } from './SignUpButton.astro'; From 7e9262082cf2eb4149e56869212444077b797414 Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Tue, 9 Jul 2024 10:57:26 -0700 Subject: [PATCH 23/23] chore(astro): Fix children prop type --- packages/astro/src/client/react/SignOutButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/client/react/SignOutButton.tsx b/packages/astro/src/client/react/SignOutButton.tsx index c61a3eb527b..efe3abf4722 100644 --- a/packages/astro/src/client/react/SignOutButton.tsx +++ b/packages/astro/src/client/react/SignOutButton.tsx @@ -17,7 +17,7 @@ export const SignOutButton = withClerk( const clickHandler = () => clerk?.signOut({ redirectUrl, sessionId }); const wrappedChildClickHandler: React.MouseEventHandler = async e => { - await safeExecute(child.props.onClick)(e); + await safeExecute((child as any).props.onClick)(e); return clickHandler(); };