@clerk/astro 3.4.1 → 3.4.2-canary.v20260610190754

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/async-local-storage.client.d.ts +4 -2
  2. package/dist/async-local-storage.client.d.ts.map +1 -0
  3. package/dist/async-local-storage.client.js +20 -24
  4. package/dist/async-local-storage.client.js.map +1 -1
  5. package/dist/async-local-storage.server.d.ts +4 -2
  6. package/dist/async-local-storage.server.d.ts.map +1 -0
  7. package/dist/async-local-storage.server.js +7 -7
  8. package/dist/async-local-storage.server.js.map +1 -1
  9. package/dist/client/index.d.ts +33 -34
  10. package/dist/client/index.d.ts.map +1 -0
  11. package/dist/client/index.js +4 -34
  12. package/dist/create-clerk-instance-AkLIq0Dz.js +162 -0
  13. package/dist/create-clerk-instance-AkLIq0Dz.js.map +1 -0
  14. package/dist/external-DHTxQaok.js +138 -0
  15. package/dist/external-DHTxQaok.js.map +1 -0
  16. package/dist/index.d.ts +6 -8
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +250 -158
  19. package/dist/index.js.map +1 -1
  20. package/dist/internal/index.d.ts +9 -9
  21. package/dist/internal/index.d.ts.map +1 -0
  22. package/dist/internal/index.js +121 -114
  23. package/dist/internal/index.js.map +1 -1
  24. package/dist/react/index.d.ts +85 -67
  25. package/dist/react/index.d.ts.map +1 -0
  26. package/dist/react/index.js +474 -568
  27. package/dist/react/index.js.map +1 -1
  28. package/dist/server/index.d.ts +25 -21
  29. package/dist/server/index.d.ts.map +1 -0
  30. package/dist/server/index.js +449 -505
  31. package/dist/server/index.js.map +1 -1
  32. package/dist/types/async-local-storage.client.d.ts +3 -0
  33. package/dist/types/async-local-storage.server.d.ts +3 -0
  34. package/dist/types/client/index.d.ts +4 -0
  35. package/dist/types/index.d.ts +5 -8
  36. package/dist/types/index.js +1 -1
  37. package/dist/types/integration/create-integration.d.ts +8 -0
  38. package/dist/types/integration/create-integration.d.ts.map +1 -1
  39. package/dist/types/integration/snippets.d.ts +45 -0
  40. package/dist/types/integration/vite-plugin-astro-config.d.ts +12 -0
  41. package/dist/types/internal/__tests__/create-clerk-instance.test.d.ts +2 -0
  42. package/dist/types/internal/__tests__/create-clerk-instance.test.d.ts.map +1 -0
  43. package/dist/types/internal/__tests__/merge-env-vars-with-params.test.d.ts +2 -0
  44. package/dist/types/internal/__tests__/merge-env-vars-with-params.test.d.ts.map +1 -0
  45. package/dist/types/internal/create-clerk-instance.d.ts +9 -0
  46. package/dist/types/internal/create-injection-script-runner.d.ts +11 -0
  47. package/dist/types/internal/index.d.ts +11 -0
  48. package/dist/types/internal/invoke-clerk-astro-js-functions.d.ts +6 -0
  49. package/dist/types/internal/merge-env-vars-with-params.d.ts +302 -0
  50. package/dist/types/internal/merge-env-vars-with-params.d.ts.map +1 -1
  51. package/dist/types/internal/mount-clerk-astro-js-components.d.ts +6 -0
  52. package/dist/types/internal/run-once.d.ts +8 -0
  53. package/dist/types/internal/swap-document.d.ts +11 -0
  54. package/dist/types/internal/types.d.ts +4 -0
  55. package/dist/types/internal/utils/generateSafeId.d.ts +9 -0
  56. package/dist/types/react/CheckoutButton.d.ts +9 -0
  57. package/dist/types/react/PlanDetailsButton.d.ts +9 -0
  58. package/dist/types/react/SignInButton.d.ts +9 -0
  59. package/dist/types/react/SignOutButton.d.ts +11 -0
  60. package/dist/types/react/SignUpButton.d.ts +9 -0
  61. package/dist/types/react/SubscriptionDetailsButton.d.ts +9 -0
  62. package/dist/types/react/__tests__/SignInButton.test.d.ts +2 -0
  63. package/dist/types/react/__tests__/SignInButton.test.d.ts.map +1 -0
  64. package/dist/types/react/controlComponents.d.ts +18 -0
  65. package/dist/types/react/hooks.d.ts +33 -0
  66. package/dist/types/react/index.d.ts +14 -0
  67. package/dist/types/react/types.d.ts +8 -0
  68. package/dist/types/react/uiComponents.d.ts +58 -0
  69. package/dist/types/react/utils.d.ts +15 -0
  70. package/dist/types/server/__tests__/get-safe-env.test.d.ts +2 -0
  71. package/dist/types/server/__tests__/get-safe-env.test.d.ts.map +1 -0
  72. package/dist/types/server/build-clerk-hotload-script.d.ts +4 -0
  73. package/dist/types/server/clerk-client.d.ts +5 -0
  74. package/dist/types/server/clerk-middleware.d.ts +33 -0
  75. package/dist/types/server/current-user.d.ts +4 -0
  76. package/dist/types/server/get-safe-env.d.ts +52 -0
  77. package/dist/types/server/index.d.ts +23 -0
  78. package/dist/types/server/keyless/file-storage.d.ts +7 -0
  79. package/dist/types/server/keyless/index.d.ts +3 -0
  80. package/dist/types/server/keyless/utils.d.ts +7 -0
  81. package/dist/types/server/route-matcher.d.ts +12 -0
  82. package/dist/types/server/server-redirect-with-auth.d.ts +7 -0
  83. package/dist/types/server/types.d.ts +20 -0
  84. package/dist/types/server/utils.d.ts +5 -0
  85. package/dist/types/stores/external.d.ts +112 -0
  86. package/dist/types/stores/external.d.ts.map +1 -1
  87. package/dist/types/stores/internal.d.ts +25 -0
  88. package/dist/types/types/index.d.ts +13 -0
  89. package/dist/types/types.d.ts +67 -0
  90. package/dist/types/utils/__tests__/feature-flags.test.d.ts +2 -0
  91. package/dist/types/utils/__tests__/feature-flags.test.d.ts.map +1 -0
  92. package/dist/types/utils/feature-flags.d.ts +2 -0
  93. package/dist/types/webhooks.d.ts +2 -0
  94. package/dist/types-DMewgJ3p.d.ts +10908 -0
  95. package/dist/types-DMewgJ3p.d.ts.map +1 -0
  96. package/dist/{types-BP9MNEP9.d.ts → types-DXY3sfKg.d.ts} +8 -6
  97. package/dist/types-DXY3sfKg.d.ts.map +1 -0
  98. package/dist/webhooks.d.ts +1 -1
  99. package/dist/webhooks.js +3 -3
  100. package/package.json +7 -7
  101. package/dist/chunk-IFEBM3MJ.js +0 -67
  102. package/dist/chunk-IFEBM3MJ.js.map +0 -1
  103. package/dist/chunk-NBEDB76N.js +0 -161
  104. package/dist/chunk-NBEDB76N.js.map +0 -1
  105. package/dist/client/index.js.map +0 -1
  106. package/dist/types/index.js.map +0 -1
  107. package/dist/types-DBUosXik.d.ts +0 -43
  108. package/dist/webhooks.js.map +0 -1
@@ -1,5 +1,7 @@
1
- import { AsyncLocalStorage } from 'node:async_hooks';
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
2
 
3
+ //#region src/async-local-storage.client.d.ts
3
4
  declare const authAsyncStorage: AsyncLocalStorage<object>;
4
-
5
+ //#endregion
5
6
  export { authAsyncStorage };
7
+ //# sourceMappingURL=async-local-storage.client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-local-storage.client.d.ts","names":[],"sources":["../src/async-local-storage.client.ts"],"mappings":";;;cAiCa,gBAAA,EAAgB,iBAAA"}
@@ -1,29 +1,25 @@
1
- // src/async-local-storage.client.ts
2
- var sharedAsyncLocalStorageNotAvailableError = new Error(
3
- "Invariant: AsyncLocalStorage accessed in runtime where it is not available"
4
- );
1
+ //#region src/async-local-storage.client.ts
2
+ const sharedAsyncLocalStorageNotAvailableError = /* @__PURE__ */ new Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available");
5
3
  var FakeAsyncLocalStorage = class {
6
- disable() {
7
- throw sharedAsyncLocalStorageNotAvailableError;
8
- }
9
- getStore() {
10
- return void 0;
11
- }
12
- run() {
13
- throw sharedAsyncLocalStorageNotAvailableError;
14
- }
15
- exit() {
16
- throw sharedAsyncLocalStorageNotAvailableError;
17
- }
18
- enterWith() {
19
- throw sharedAsyncLocalStorageNotAvailableError;
20
- }
4
+ disable() {
5
+ throw sharedAsyncLocalStorageNotAvailableError;
6
+ }
7
+ getStore() {}
8
+ run() {
9
+ throw sharedAsyncLocalStorageNotAvailableError;
10
+ }
11
+ exit() {
12
+ throw sharedAsyncLocalStorageNotAvailableError;
13
+ }
14
+ enterWith() {
15
+ throw sharedAsyncLocalStorageNotAvailableError;
16
+ }
21
17
  };
22
18
  function createAsyncLocalStorage() {
23
- return new FakeAsyncLocalStorage();
19
+ return new FakeAsyncLocalStorage();
24
20
  }
25
- var authAsyncStorage = createAsyncLocalStorage();
26
- export {
27
- authAsyncStorage
28
- };
21
+ const authAsyncStorage = createAsyncLocalStorage();
22
+
23
+ //#endregion
24
+ export { authAsyncStorage };
29
25
  //# sourceMappingURL=async-local-storage.client.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/async-local-storage.client.ts"],"sourcesContent":["import type { AsyncLocalStorage } from 'node:async_hooks';\n\nconst sharedAsyncLocalStorageNotAvailableError = new Error(\n 'Invariant: AsyncLocalStorage accessed in runtime where it is not available',\n);\n\nclass FakeAsyncLocalStorage<Store extends object> implements AsyncLocalStorage<Store> {\n disable(): void {\n throw sharedAsyncLocalStorageNotAvailableError;\n }\n\n getStore(): Store | undefined {\n // This fake implementation of AsyncLocalStorage always returns `undefined`.\n return undefined;\n }\n\n run<R>(): R {\n throw sharedAsyncLocalStorageNotAvailableError;\n }\n\n exit<R>(): R {\n throw sharedAsyncLocalStorageNotAvailableError;\n }\n\n enterWith(): void {\n throw sharedAsyncLocalStorageNotAvailableError;\n }\n}\n\nfunction createAsyncLocalStorage<Store extends object>(): AsyncLocalStorage<Store> {\n return new FakeAsyncLocalStorage();\n}\n\nexport const authAsyncStorage = createAsyncLocalStorage();\n"],"mappings":";AAEA,IAAM,2CAA2C,IAAI;AAAA,EACnD;AACF;AAEA,IAAM,wBAAN,MAAsF;AAAA,EACpF,UAAgB;AACd,UAAM;AAAA,EACR;AAAA,EAEA,WAA8B;AAE5B,WAAO;AAAA,EACT;AAAA,EAEA,MAAY;AACV,UAAM;AAAA,EACR;AAAA,EAEA,OAAa;AACX,UAAM;AAAA,EACR;AAAA,EAEA,YAAkB;AAChB,UAAM;AAAA,EACR;AACF;AAEA,SAAS,0BAA0E;AACjF,SAAO,IAAI,sBAAsB;AACnC;AAEO,IAAM,mBAAmB,wBAAwB;","names":[]}
1
+ {"version":3,"file":"async-local-storage.client.js","names":[],"sources":["../src/async-local-storage.client.ts"],"sourcesContent":["import type { AsyncLocalStorage } from 'node:async_hooks';\n\nconst sharedAsyncLocalStorageNotAvailableError = new Error(\n 'Invariant: AsyncLocalStorage accessed in runtime where it is not available',\n);\n\nclass FakeAsyncLocalStorage<Store extends object> implements AsyncLocalStorage<Store> {\n disable(): void {\n throw sharedAsyncLocalStorageNotAvailableError;\n }\n\n getStore(): Store | undefined {\n // This fake implementation of AsyncLocalStorage always returns `undefined`.\n return undefined;\n }\n\n run<R>(): R {\n throw sharedAsyncLocalStorageNotAvailableError;\n }\n\n exit<R>(): R {\n throw sharedAsyncLocalStorageNotAvailableError;\n }\n\n enterWith(): void {\n throw sharedAsyncLocalStorageNotAvailableError;\n }\n}\n\nfunction createAsyncLocalStorage<Store extends object>(): AsyncLocalStorage<Store> {\n return new FakeAsyncLocalStorage();\n}\n\nexport const authAsyncStorage = createAsyncLocalStorage();\n"],"mappings":";AAEA,MAAM,2DAA2C,IAAI,MACnD,4EACF;AAEA,IAAM,wBAAN,MAAsF;CACpF,UAAgB;EACd,MAAM;CACR;CAEA,WAA8B,CAG9B;CAEA,MAAY;EACV,MAAM;CACR;CAEA,OAAa;EACX,MAAM;CACR;CAEA,YAAkB;EAChB,MAAM;CACR;AACF;AAEA,SAAS,0BAA0E;CACjF,OAAO,IAAI,sBAAsB;AACnC;AAEA,MAAa,mBAAmB,wBAAwB"}
@@ -1,5 +1,7 @@
1
- import { AsyncLocalStorage } from 'node:async_hooks';
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
2
 
3
+ //#region src/async-local-storage.server.d.ts
3
4
  declare const authAsyncStorage: AsyncLocalStorage<object>;
4
-
5
+ //#endregion
5
6
  export { authAsyncStorage };
7
+ //# sourceMappingURL=async-local-storage.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-local-storage.server.d.ts","names":[],"sources":["../src/async-local-storage.server.ts"],"mappings":";;;cAOa,gBAAA,EAAgB,iBAAA"}
@@ -1,10 +1,10 @@
1
- // src/async-local-storage.server.ts
1
+ //#region src/async-local-storage.server.ts
2
2
  async function createAsyncLocalStorage() {
3
- const { AsyncLocalStorage } = await import("async_hooks");
4
- return new AsyncLocalStorage();
3
+ const { AsyncLocalStorage } = await import("node:async_hooks");
4
+ return new AsyncLocalStorage();
5
5
  }
6
- var authAsyncStorage = await createAsyncLocalStorage();
7
- export {
8
- authAsyncStorage
9
- };
6
+ const authAsyncStorage = await createAsyncLocalStorage();
7
+
8
+ //#endregion
9
+ export { authAsyncStorage };
10
10
  //# sourceMappingURL=async-local-storage.server.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/async-local-storage.server.ts"],"sourcesContent":["import { type AsyncLocalStorage } from 'node:async_hooks';\n\nasync function createAsyncLocalStorage<Store extends object>(): Promise<AsyncLocalStorage<Store>> {\n const { AsyncLocalStorage } = await import('node:async_hooks');\n return new AsyncLocalStorage<Store>();\n}\n\nexport const authAsyncStorage = await createAsyncLocalStorage();\n"],"mappings":";AAEA,eAAe,0BAAmF;AAChG,QAAM,EAAE,kBAAkB,IAAI,MAAM,OAAO,aAAkB;AAC7D,SAAO,IAAI,kBAAyB;AACtC;AAEO,IAAM,mBAAmB,MAAM,wBAAwB;","names":[]}
1
+ {"version":3,"file":"async-local-storage.server.js","names":[],"sources":["../src/async-local-storage.server.ts"],"sourcesContent":["import { type AsyncLocalStorage } from 'node:async_hooks';\n\nasync function createAsyncLocalStorage<Store extends object>(): Promise<AsyncLocalStorage<Store>> {\n const { AsyncLocalStorage } = await import('node:async_hooks');\n return new AsyncLocalStorage<Store>();\n}\n\nexport const authAsyncStorage = await createAsyncLocalStorage();\n"],"mappings":";AAEA,eAAe,0BAAmF;CAChG,MAAM,EAAE,sBAAsB,MAAM,OAAO;CAC3C,OAAO,IAAI,kBAAyB;AACtC;AAEA,MAAa,mBAAmB,MAAM,wBAAwB"}
@@ -1,20 +1,18 @@
1
- import { b as AstroClerkUpdateOptions } from '../types-DBUosXik.js';
2
- import { Ui } from '@clerk/ui/internal';
3
- import * as _clerk_shared_types from '@clerk/shared/types';
4
- import * as _clerk_shared__chunks_index_bgWBrAaq from '@clerk/shared/_chunks/index-bgWBrAaq';
5
- import * as nanostores from 'nanostores';
6
- export { getToken } from '@clerk/shared/getToken';
7
- import '@clerk/shared/ui';
1
+ import { r as AstroClerkUpdateOptions, s as Ui } from "../types-DMewgJ3p.js";
2
+ import { getToken } from "@clerk/shared/getToken";
3
+ import { SignedInSessionResource } from "@clerk/shared/types";
8
4
 
5
+ //#region src/internal/create-clerk-instance.d.ts
9
6
  declare function updateClerkOptions<TUi extends Ui = Ui>(options: AstroClerkUpdateOptions<TUi>): void;
10
-
7
+ //#endregion
8
+ //#region src/stores/external.d.ts
11
9
  /**
12
10
  * A client side store that returns the loaded state of clerk-js.
13
11
  *
14
12
  * @example
15
13
  * $isLoadedStore.subscribe((authloaded => console.log(loaded))
16
14
  */
17
- declare const $isLoadedStore: nanostores.ReadableAtom<boolean>;
15
+ declare const $isLoadedStore: import("nanostores").ReadableAtom<boolean>;
18
16
  /**
19
17
  * A client side store that is prepopulated with the authentication context during SSR.
20
18
  * It is a nanostore, for instructions on how to use nanostores please review the [documentation](https://github.com/nanostores/nanostores)
@@ -22,20 +20,20 @@ declare const $isLoadedStore: nanostores.ReadableAtom<boolean>;
22
20
  * @example
23
21
  * $authStore.subscribe((auth) => console.log(auth.userId))
24
22
  */
25
- declare const $authStore: nanostores.ReadableAtom<{
26
- userId: string | null | undefined;
27
- user: _clerk_shared__chunks_index_bgWBrAaq.Cs | null | undefined;
28
- sessionId: string | null | undefined;
29
- session: _clerk_shared__chunks_index_bgWBrAaq.cs | null | undefined;
30
- sessionStatus: "active" | "pending" | undefined;
31
- sessionClaims: _clerk_shared__chunks_index_bgWBrAaq.do | null | undefined;
32
- organization: _clerk_shared__chunks_index_bgWBrAaq.jo | null | undefined;
33
- orgId: string | null | undefined;
34
- orgRole: string | null | undefined;
35
- orgSlug: string | null | undefined;
36
- orgPermissions: _clerk_shared__chunks_index_bgWBrAaq.Fm<_clerk_shared__chunks_index_bgWBrAaq.vo>[] | null | undefined;
37
- actor: _clerk_shared__chunks_index_bgWBrAaq.oo | null | undefined;
38
- factorVerificationAge: [number, number] | null;
23
+ declare const $authStore: import("nanostores").ReadableAtom<{
24
+ userId: string | null | undefined;
25
+ user: import("@clerk/shared/types").UserResource | null | undefined;
26
+ sessionId: string | null | undefined;
27
+ session: SignedInSessionResource | null | undefined;
28
+ sessionStatus: "active" | "pending" | undefined;
29
+ sessionClaims: import("@clerk/shared/types").JwtPayload | null | undefined;
30
+ organization: import("@clerk/shared/types").OrganizationResource | null | undefined;
31
+ orgId: string | null | undefined;
32
+ orgRole: string | null | undefined;
33
+ orgSlug: string | null | undefined;
34
+ orgPermissions: import("@clerk/shared/types").Autocomplete<import("@clerk/shared/types").OrganizationSystemPermissionKey>[] | null | undefined;
35
+ actor: import("@clerk/shared/types").ActClaim | null | undefined;
36
+ factorVerificationAge: [number, number] | null;
39
37
  }>;
40
38
  /**
41
39
  * A client side store that is populated after clerk-js has loaded.
@@ -45,7 +43,7 @@ declare const $authStore: nanostores.ReadableAtom<{
45
43
  * @example
46
44
  * $userStore.subscribe((user) => console.log(user.id))
47
45
  */
48
- declare const $userStore: nanostores.ReadableAtom<_clerk_shared__chunks_index_bgWBrAaq.Cs | null | undefined>;
46
+ declare const $userStore: import("nanostores").ReadableAtom<import("@clerk/shared/types").UserResource | null | undefined>;
49
47
  /**
50
48
  * A client side store that is populated after clerk-js has loaded.
51
49
  * The store returns the session of the authenticated user or `null`.
@@ -54,7 +52,7 @@ declare const $userStore: nanostores.ReadableAtom<_clerk_shared__chunks_index_bg
54
52
  * @example
55
53
  * $sessionStore.subscribe((session) => console.log(session.id))
56
54
  */
57
- declare const $sessionStore: nanostores.ReadableAtom<_clerk_shared_types.ActiveSessionResource | _clerk_shared_types.PendingSessionResource | null | undefined>;
55
+ declare const $sessionStore: import("nanostores").ReadableAtom<import("@clerk/shared/types").ActiveSessionResource | import("@clerk/shared/types").PendingSessionResource | null | undefined>;
58
56
  /**
59
57
  * A client side store that is populated after clerk-js has loaded.
60
58
  * The store returns the Active Organization of the authenticated user or `null`.
@@ -63,7 +61,7 @@ declare const $sessionStore: nanostores.ReadableAtom<_clerk_shared_types.ActiveS
63
61
  * @example
64
62
  * $organizationStore.subscribe((org) => console.log(org.id))
65
63
  */
66
- declare const $organizationStore: nanostores.ReadableAtom<_clerk_shared__chunks_index_bgWBrAaq.jo | null | undefined>;
64
+ declare const $organizationStore: import("nanostores").ReadableAtom<import("@clerk/shared/types").OrganizationResource | null | undefined>;
67
65
  /**
68
66
  * A client side store that is populated after clerk-js has loaded.
69
67
  * The store returns the clerk client or `null`.
@@ -72,7 +70,7 @@ declare const $organizationStore: nanostores.ReadableAtom<_clerk_shared__chunks_
72
70
  * @example
73
71
  * $clientStore.subscribe((client) => console.log(client?.signedInSessions?.length))
74
72
  */
75
- declare const $clientStore: nanostores.ReadableAtom<_clerk_shared_types.ClientResource | null | undefined>;
73
+ declare const $clientStore: import("nanostores").ReadableAtom<import("@clerk/shared/types").ClientResource | null | undefined>;
76
74
  /**
77
75
  * A client side store that is populated after clerk-js is instanciated.
78
76
  * The store returns the clerk instance or `null`.
@@ -81,7 +79,7 @@ declare const $clientStore: nanostores.ReadableAtom<_clerk_shared_types.ClientRe
81
79
  * @example
82
80
  * $clerkStore.subscribe((clerk) => console.log(clerk.publishableKey))
83
81
  */
84
- declare const $clerkStore: nanostores.ReadableAtom<_clerk_shared_types.Clerk | null>;
82
+ declare const $clerkStore: import("nanostores").ReadableAtom<import("@clerk/shared/types").Clerk | null>;
85
83
  /**
86
84
  * A client side store that is populated after clerk-js has loaded.
87
85
  * The store returns all the sessions of the current clerk client or `null`.
@@ -90,7 +88,7 @@ declare const $clerkStore: nanostores.ReadableAtom<_clerk_shared_types.Clerk | n
90
88
  * @example
91
89
  * $sessionListStore.subscribe((sessionList) => sessionList.map((session) => console.log('Session id:', sessino.id) ))
92
90
  */
93
- declare const $sessionListStore: nanostores.ReadableAtom<_clerk_shared_types.SessionResource[] | undefined>;
91
+ declare const $sessionListStore: import("nanostores").ReadableAtom<import("@clerk/shared/types").SessionResource[] | undefined>;
94
92
  /**
95
93
  * A client side store that is populated after clerk-js has loaded.
96
94
  * The store returns a `SignInResource` or `null`.
@@ -99,7 +97,7 @@ declare const $sessionListStore: nanostores.ReadableAtom<_clerk_shared_types.Ses
99
97
  * @example
100
98
  * $signInStore.subscribe((signIn) => console.log(signIn.status))
101
99
  */
102
- declare const $signInStore: nanostores.ReadableAtom<_clerk_shared_types.SignInResource | undefined>;
100
+ declare const $signInStore: import("nanostores").ReadableAtom<import("@clerk/shared/types").SignInResource | undefined>;
103
101
  /**
104
102
  * A client side store that is populated after clerk-js has loaded.
105
103
  * The store returns a `SignUpResource` or `null`.
@@ -108,7 +106,7 @@ declare const $signInStore: nanostores.ReadableAtom<_clerk_shared_types.SignInRe
108
106
  * @example
109
107
  * $signUpStore.subscribe((signUp) => console.log(signUp.status))
110
108
  */
111
- declare const $signUpStore: nanostores.ReadableAtom<_clerk_shared_types.SignUpResource | undefined>;
109
+ declare const $signUpStore: import("nanostores").ReadableAtom<import("@clerk/shared/types").SignUpResource | undefined>;
112
110
  /**
113
111
  * A client side store that is populated after clerk-js has loaded.
114
112
  * The store returns a `BillingNamespace` or `null`.
@@ -117,6 +115,7 @@ declare const $signUpStore: nanostores.ReadableAtom<_clerk_shared_types.SignUpRe
117
115
  * @example
118
116
  * $billingStore.subscribe((billing) => billing.getPlans().then((plans) => console.log(plans.data.length)))
119
117
  */
120
- declare const $billingStore: nanostores.ReadableAtom<_clerk_shared_types.BillingNamespace | undefined>;
121
-
122
- export { $authStore, $billingStore, $clerkStore, $clientStore, $isLoadedStore, $organizationStore, $sessionListStore, $sessionStore, $signInStore, $signUpStore, $userStore, updateClerkOptions };
118
+ declare const $billingStore: import("nanostores").ReadableAtom<import("@clerk/shared/types").BillingNamespace | undefined>;
119
+ //#endregion
120
+ export { $authStore, $billingStore, $clerkStore, $clientStore, $isLoadedStore, $organizationStore, $sessionListStore, $sessionStore, $signInStore, $signUpStore, $userStore, getToken, updateClerkOptions };
121
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/internal/create-clerk-instance.ts","../../src/stores/external.ts"],"mappings":";;;;;iBA+FS,kBAAA,aAA+B,EAAA,GAAK,EAAA,EAAI,OAAA,EAAS,uBAAA,CAAwB,GAAA;;;;;;;AA5DzD;;cCtBZ,cAAA,uBAAc,YAAA;;;;;;;;cASd,UAAA,uBAAU,YAAA;;;;WAYrB,uBAAA;;;;;;;;;;;AAZF;;;;;;;;AAAA,cAsBa,UAAA,uBAAU,YAAA,+BAAA,YAAA;;;;;;;;;cAUV,aAAA,uBAAa,YAAA,+BAAA,qBAAA,iCAAA,sBAAA;;;;;;;;;cAUb,kBAAA,uBAAkB,YAAA,+BAAA,oBAAA;AApB/B;;;;AAAuB;AAUvB;;;AAVA,cA8Ba,YAAA,uBAAY,YAAA,+BAAA,cAAA;;;;;AApBC;AAU1B;;;cAoBa,WAAA,uBAAW,YAAA,+BAAA,KAAA;AApBO;AAU/B;;;;AAAyB;AAUzB;;AApB+B,cA8BlB,iBAAA,uBAAiB,YAAA,+BAAA,eAAA;;AAVN;AAUxB;;;;AAA8B;AAU9B;cAAa,YAAA,uBAAY,YAAA,+BAAA,cAAA;;;AAAA;AAUzB;;;;AAAyB;cAAZ,YAAA,uBAAY,YAAA,+BAAA,cAAA;;;;AAUC;;;;;cAAb,aAAA,uBAAa,YAAA,+BAAA,gBAAA"}
@@ -1,35 +1,5 @@
1
- import {
2
- updateClerkOptions
3
- } from "../chunk-NBEDB76N.js";
4
- import {
5
- $authStore,
6
- $billingStore,
7
- $clerkStore,
8
- $clientStore,
9
- $isLoadedStore,
10
- $organizationStore,
11
- $sessionListStore,
12
- $sessionStore,
13
- $signInStore,
14
- $signUpStore,
15
- $userStore
16
- } from "../chunk-IFEBM3MJ.js";
17
-
18
- // src/client/index.ts
1
+ import { a as $isLoadedStore, c as $sessionStore, d as $userStore, i as $clientStore, l as $signInStore, n as $billingStore, o as $organizationStore, r as $clerkStore, s as $sessionListStore, t as $authStore, u as $signUpStore } from "../external-DHTxQaok.js";
2
+ import { n as updateClerkOptions } from "../create-clerk-instance-AkLIq0Dz.js";
19
3
  import { getToken } from "@clerk/shared/getToken";
20
- export {
21
- $authStore,
22
- $billingStore,
23
- $clerkStore,
24
- $clientStore,
25
- $isLoadedStore,
26
- $organizationStore,
27
- $sessionListStore,
28
- $sessionStore,
29
- $signInStore,
30
- $signUpStore,
31
- $userStore,
32
- getToken,
33
- updateClerkOptions
34
- };
35
- //# sourceMappingURL=index.js.map
4
+
5
+ export { $authStore, $billingStore, $clerkStore, $clientStore, $isLoadedStore, $organizationStore, $sessionListStore, $sessionStore, $signInStore, $signUpStore, $userStore, getToken, updateClerkOptions };
@@ -0,0 +1,162 @@
1
+ import { f as $clerk, p as $csrState, r as $clerkStore } from "./external-DHTxQaok.js";
2
+ import { loadClerkJSScript, loadClerkUIScript, setClerkJSLoadingErrorPackageName } from "@clerk/shared/loadClerkJsScript";
3
+
4
+ //#region src/internal/invoke-clerk-astro-js-functions.ts
5
+ /**
6
+ * Loop through any Astro component that has requested to invoke a function and invoke it with its respective props.
7
+ */
8
+ const invokeClerkAstroJSFunctions = () => {
9
+ ["handleRedirectCallback"].forEach((fnName) => {
10
+ document.querySelectorAll(`[data-clerk-function-id^="clerk-${fnName}"]`).forEach((el) => {
11
+ const id = el.getAttribute("data-clerk-function-id");
12
+ const props = window.__astro_clerk_function_props?.get(fnName)?.get(id) ?? {};
13
+ $clerk.get()?.[fnName]?.(props);
14
+ });
15
+ });
16
+ };
17
+
18
+ //#endregion
19
+ //#region src/internal/mount-clerk-astro-js-components.ts
20
+ /**
21
+ * Loop through any Astro component that has requested to mount a UI component and mount it with its respective props.
22
+ */
23
+ const mountAllClerkAstroJSComponents = () => {
24
+ Object.entries({
25
+ "create-organization": "mountCreateOrganization",
26
+ "organization-list": "mountOrganizationList",
27
+ "organization-profile": "mountOrganizationProfile",
28
+ "organization-switcher": "mountOrganizationSwitcher",
29
+ "user-avatar": "mountUserAvatar",
30
+ "user-button": "mountUserButton",
31
+ "user-profile": "mountUserProfile",
32
+ "sign-in": "mountSignIn",
33
+ "sign-up": "mountSignUp",
34
+ "google-one-tap": "openGoogleOneTap",
35
+ waitlist: "mountWaitlist",
36
+ "pricing-table": "mountPricingTable",
37
+ "api-keys": "mountAPIKeys"
38
+ }).forEach(([category, mountFn]) => {
39
+ document.querySelectorAll(`[data-clerk-id^="clerk-${category}"]`).forEach((el) => {
40
+ const clerkId = el.getAttribute("data-clerk-id");
41
+ const props = window.__astro_clerk_component_props?.get(category)?.get(clerkId);
42
+ if (el) $clerk.get()?.[mountFn](el, props);
43
+ });
44
+ });
45
+ };
46
+
47
+ //#endregion
48
+ //#region src/internal/run-once.ts
49
+ /**
50
+ * Prevents mounting components multiple times when the `createClerkInstanceInternal` was been called twice without await first
51
+ * This is useful as the "integration" may call the function twice at the same time.
52
+ */
53
+ const runOnce = (onFirst) => {
54
+ let hasRun = false;
55
+ return (params) => {
56
+ if (hasRun) {
57
+ const clerkJSInstance = window.Clerk;
58
+ return new Promise((res) => {
59
+ if (!clerkJSInstance) return res(false);
60
+ if (clerkJSInstance.loaded) {
61
+ mountAllClerkAstroJSComponents();
62
+ invokeClerkAstroJSFunctions();
63
+ }
64
+ return res(clerkJSInstance.loaded);
65
+ });
66
+ }
67
+ /**
68
+ * Probably html streaming has delayed the component from mounting immediately.
69
+ * In Astro, js modules will start executing only after html streaming has ended.
70
+ */
71
+ hasRun = true;
72
+ return onFirst(params);
73
+ };
74
+ };
75
+
76
+ //#endregion
77
+ //#region src/internal/create-clerk-instance.ts
78
+ let initOptions;
79
+ setClerkJSLoadingErrorPackageName("@clerk/astro");
80
+ function createNavigationHandler(windowNav) {
81
+ return (to, opts) => {
82
+ if (opts?.__internal_metadata?.navigationType === "internal") windowNav(history.state, "", to);
83
+ else opts?.windowNavigate(to);
84
+ };
85
+ }
86
+ /**
87
+ * Prevents firing clerk.load() multiple times
88
+ */
89
+ const createClerkInstance = runOnce(createClerkInstanceInternal);
90
+ async function createClerkInstanceInternal(options) {
91
+ const clerkJsChunk = getClerkJsEntryChunk(options);
92
+ const ClerkUI = getClerkUIEntryChunk(options);
93
+ await clerkJsChunk;
94
+ if (!window.Clerk) throw new Error("Failed to download latest ClerkJS. Contact support@clerk.com.");
95
+ const clerkJSInstance = window.Clerk;
96
+ if (!$clerk.get()) $clerk.set(clerkJSInstance);
97
+ const internalOptions = options;
98
+ const keylessClaimUrl = internalOptions.__internal_keylessClaimUrl;
99
+ const keylessApiKeysUrl = internalOptions.__internal_keylessApiKeysUrl;
100
+ const clerkOptions = {
101
+ routerPush: createNavigationHandler(window.history.pushState.bind(window.history)),
102
+ routerReplace: createNavigationHandler(window.history.replaceState.bind(window.history)),
103
+ ...options,
104
+ ui: {
105
+ ...options?.ui,
106
+ ClerkUI
107
+ },
108
+ ...keylessClaimUrl && { __internal_keyless_claimKeylessApplicationUrl: keylessClaimUrl },
109
+ ...keylessApiKeysUrl && { __internal_keyless_copyInstanceKeysUrl: keylessApiKeysUrl }
110
+ };
111
+ initOptions = clerkOptions;
112
+ return clerkJSInstance.load(clerkOptions).then(() => {
113
+ $csrState.setKey("isLoaded", true);
114
+ $clerkStore.notify();
115
+ mountAllClerkAstroJSComponents();
116
+ invokeClerkAstroJSFunctions();
117
+ clerkJSInstance.addListener((payload) => {
118
+ $csrState.setKey("client", payload.client);
119
+ $csrState.setKey("user", payload.user);
120
+ $csrState.setKey("session", payload.session);
121
+ $csrState.setKey("organization", payload.organization);
122
+ });
123
+ }).catch(() => {});
124
+ }
125
+ function updateClerkOptions(options) {
126
+ const clerk = $clerk.get();
127
+ if (!clerk) throw new Error("Missing clerk instance");
128
+ const updateOptions = {
129
+ options: {
130
+ ...initOptions,
131
+ ...options
132
+ },
133
+ appearance: {
134
+ ...initOptions?.appearance,
135
+ ...options.appearance
136
+ }
137
+ };
138
+ clerk.__internal_updateProps(updateOptions);
139
+ }
140
+ /**
141
+ * Loads clerk-js script if not already loaded.
142
+ * Returns early if window.Clerk already exists.
143
+ */
144
+ async function getClerkJsEntryChunk(options) {
145
+ await loadClerkJSScript(options);
146
+ }
147
+ /**
148
+ * Gets the ClerkUI constructor, either from options or by loading the script.
149
+ * Returns early if window.__internal_ClerkUICtor already exists.
150
+ * Returns undefined when prefetchUI={false} (no UI needed).
151
+ */
152
+ async function getClerkUIEntryChunk(options) {
153
+ if (options?.ui?.ClerkUI) return options.ui.ClerkUI;
154
+ if (options?.ui || options?.prefetchUI === false) return;
155
+ await loadClerkUIScript(options);
156
+ if (!window.__internal_ClerkUICtor) throw new Error("Failed to download latest Clerk UI. Contact support@clerk.com.");
157
+ return window.__internal_ClerkUICtor;
158
+ }
159
+
160
+ //#endregion
161
+ export { updateClerkOptions as n, createClerkInstance as t };
162
+ //# sourceMappingURL=create-clerk-instance-AkLIq0Dz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-clerk-instance-AkLIq0Dz.js","names":[],"sources":["../src/internal/invoke-clerk-astro-js-functions.ts","../src/internal/mount-clerk-astro-js-components.ts","../src/internal/run-once.ts","../src/internal/create-clerk-instance.ts"],"sourcesContent":["import { $clerk } from '../stores/internal';\n\n/**\n * Loop through any Astro component that has requested to invoke a function and invoke it with its respective props.\n */\nconst invokeClerkAstroJSFunctions = () => {\n const functionNames = ['handleRedirectCallback'] as const;\n\n functionNames.forEach(fnName => {\n const elementsOfCategory = document.querySelectorAll(`[data-clerk-function-id^=\"clerk-${fnName}\"]`);\n elementsOfCategory.forEach(el => {\n const id = el.getAttribute('data-clerk-function-id');\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const props = window.__astro_clerk_function_props?.get(fnName)?.get(id!) ?? {};\n void $clerk.get()?.[fnName]?.(props);\n });\n });\n};\n\nexport { invokeClerkAstroJSFunctions };\n","import type { Clerk } from '@clerk/shared/types';\n\nimport { $clerk } from '../stores/internal';\nimport type { InternalUIComponentId } from '../types';\n\n/**\n * Loop through any Astro component that has requested to mount a UI component and mount it with its respective props.\n */\nconst mountAllClerkAstroJSComponents = () => {\n const mountFns = {\n 'create-organization': 'mountCreateOrganization',\n 'organization-list': 'mountOrganizationList',\n 'organization-profile': 'mountOrganizationProfile',\n 'organization-switcher': 'mountOrganizationSwitcher',\n 'user-avatar': 'mountUserAvatar',\n 'user-button': 'mountUserButton',\n 'user-profile': 'mountUserProfile',\n 'sign-in': 'mountSignIn',\n 'sign-up': 'mountSignUp',\n 'google-one-tap': 'openGoogleOneTap',\n waitlist: 'mountWaitlist',\n 'pricing-table': 'mountPricingTable',\n 'api-keys': 'mountAPIKeys',\n } as const satisfies Record<InternalUIComponentId, keyof Clerk>;\n\n Object.entries(mountFns).forEach(([category, mountFn]) => {\n const elementsOfCategory = document.querySelectorAll(`[data-clerk-id^=\"clerk-${category}\"]`);\n elementsOfCategory.forEach(el => {\n const clerkId = el.getAttribute('data-clerk-id') as string;\n const props = window.__astro_clerk_component_props?.get(category)?.get(clerkId);\n if (el) {\n $clerk.get()?.[mountFn](el as HTMLDivElement, props);\n }\n });\n });\n};\n\nexport { mountAllClerkAstroJSComponents };\n","import { invokeClerkAstroJSFunctions } from './invoke-clerk-astro-js-functions';\nimport { mountAllClerkAstroJSComponents } from './mount-clerk-astro-js-components';\nimport type { CreateClerkInstanceInternalFn } from './types';\n\n/**\n * Prevents mounting components multiple times when the `createClerkInstanceInternal` was been called twice without await first\n * This is useful as the \"integration\" may call the function twice at the same time.\n */\nconst runOnce = (onFirst: CreateClerkInstanceInternalFn) => {\n let hasRun = false;\n return (params: Parameters<CreateClerkInstanceInternalFn>[0]) => {\n if (hasRun) {\n const clerkJSInstance = window.Clerk;\n return new Promise(res => {\n if (!clerkJSInstance) {\n return res(false);\n }\n\n if (clerkJSInstance.loaded) {\n mountAllClerkAstroJSComponents();\n invokeClerkAstroJSFunctions();\n }\n return res(clerkJSInstance.loaded);\n });\n }\n /**\n * Probably html streaming has delayed the component from mounting immediately.\n * In Astro, js modules will start executing only after html streaming has ended.\n */\n hasRun = true;\n return onFirst(params);\n };\n};\n\nexport { runOnce };\n","import {\n loadClerkJSScript,\n loadClerkUIScript,\n setClerkJSLoadingErrorPackageName,\n} from '@clerk/shared/loadClerkJsScript';\nimport type { ClerkOptions } from '@clerk/shared/types';\nimport type { ClerkUIConstructor } from '@clerk/shared/ui';\nimport type { Ui } from '@clerk/ui/internal';\n\nimport { $clerkStore } from '../stores/external';\nimport { $clerk, $csrState } from '../stores/internal';\nimport type { AstroClerkCreateInstanceParams, AstroClerkUpdateOptions, InternalRuntimeOptions } from '../types';\nimport { invokeClerkAstroJSFunctions } from './invoke-clerk-astro-js-functions';\nimport { mountAllClerkAstroJSComponents } from './mount-clerk-astro-js-components';\nimport { runOnce } from './run-once';\n\nlet initOptions: ClerkOptions | undefined;\n\nsetClerkJSLoadingErrorPackageName(PACKAGE_NAME);\n\nfunction createNavigationHandler(\n windowNav: typeof window.history.pushState | typeof window.history.replaceState,\n): Exclude<ClerkOptions['routerPush'], undefined> | Exclude<ClerkOptions['routerReplace'], undefined> {\n return (to, opts) => {\n if (opts?.__internal_metadata?.navigationType === 'internal') {\n windowNav(history.state, '', to);\n } else {\n opts?.windowNavigate(to);\n }\n };\n}\n\n/**\n * Prevents firing clerk.load() multiple times\n */\nconst createClerkInstance = runOnce(createClerkInstanceInternal);\n\nasync function createClerkInstanceInternal<TUi extends Ui = Ui>(options?: AstroClerkCreateInstanceParams<TUi>) {\n // Load clerk-js and clerk-ui in parallel.\n // Both functions return early if the scripts are already loaded\n // (e.g., via middleware-injected script tags in the HTML head).\n const clerkJsChunk = getClerkJsEntryChunk(options);\n const ClerkUI = getClerkUIEntryChunk(options);\n\n await clerkJsChunk;\n\n if (!window.Clerk) {\n throw new Error('Failed to download latest ClerkJS. Contact support@clerk.com.');\n }\n\n const clerkJSInstance = window.Clerk;\n\n if (!$clerk.get()) {\n $clerk.set(clerkJSInstance);\n }\n\n const internalOptions = options as AstroClerkCreateInstanceParams<TUi> & InternalRuntimeOptions;\n const keylessClaimUrl = internalOptions.__internal_keylessClaimUrl;\n const keylessApiKeysUrl = internalOptions.__internal_keylessApiKeysUrl;\n\n const clerkOptions = {\n routerPush: createNavigationHandler(window.history.pushState.bind(window.history)),\n routerReplace: createNavigationHandler(window.history.replaceState.bind(window.history)),\n ...options,\n // Pass the clerk-ui constructor promise to clerk.load()\n ui: { ...options?.ui, ClerkUI },\n ...(keylessClaimUrl && { __internal_keyless_claimKeylessApplicationUrl: keylessClaimUrl }),\n ...(keylessApiKeysUrl && { __internal_keyless_copyInstanceKeysUrl: keylessApiKeysUrl }),\n } as unknown as ClerkOptions;\n\n initOptions = clerkOptions;\n\n return clerkJSInstance\n .load(clerkOptions)\n .then(() => {\n $csrState.setKey('isLoaded', true);\n // Notify subscribers that $clerkStore has been loaded.\n // We're doing this because nanostores uses `===` for equality\n // and just by setting the value to `window.Clerk` again won't trigger an update.\n // We notify only once as this store is for advanced users.\n $clerkStore.notify();\n\n mountAllClerkAstroJSComponents();\n invokeClerkAstroJSFunctions();\n\n clerkJSInstance.addListener(payload => {\n $csrState.setKey('client', payload.client);\n $csrState.setKey('user', payload.user);\n $csrState.setKey('session', payload.session);\n $csrState.setKey('organization', payload.organization);\n });\n })\n .catch(() => {});\n}\n\nfunction updateClerkOptions<TUi extends Ui = Ui>(options: AstroClerkUpdateOptions<TUi>) {\n const clerk = $clerk.get();\n if (!clerk) {\n throw new Error('Missing clerk instance');\n }\n const updateOptions = {\n options: { ...initOptions, ...options },\n appearance: { ...initOptions?.appearance, ...options.appearance },\n } as unknown as { options: ClerkOptions; appearance?: any };\n // `__internal_updateProps` is not exposed as public API from `@clerk/types`\n void (clerk as any).__internal_updateProps(updateOptions);\n}\n\n/**\n * Loads clerk-js script if not already loaded.\n * Returns early if window.Clerk already exists.\n */\nasync function getClerkJsEntryChunk<TUi extends Ui = Ui>(options?: AstroClerkCreateInstanceParams<TUi>): Promise<void> {\n await loadClerkJSScript(options);\n}\n\n/**\n * Gets the ClerkUI constructor, either from options or by loading the script.\n * Returns early if window.__internal_ClerkUICtor already exists.\n * Returns undefined when prefetchUI={false} (no UI needed).\n */\nasync function getClerkUIEntryChunk<TUi extends Ui = Ui>(\n options?: AstroClerkCreateInstanceParams<TUi>,\n): Promise<ClerkUIConstructor | undefined> {\n // Support bundled UI via ui.ClerkUI prop\n if (options?.ui?.ClerkUI) {\n return options.ui.ClerkUI;\n }\n\n // Skip CDN prefetch when ui prop is passed (bundled UI) or prefetchUI is false\n if (options?.ui || options?.prefetchUI === false) {\n return undefined;\n }\n\n await loadClerkUIScript(options as any);\n\n if (!window.__internal_ClerkUICtor) {\n throw new Error('Failed to download latest Clerk UI. Contact support@clerk.com.');\n }\n\n return window.__internal_ClerkUICtor;\n}\n\nexport { createClerkInstance, updateClerkOptions };\n"],"mappings":"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"}
@@ -0,0 +1,138 @@
1
+ import { atom, batched, computed, map, onMount } from "nanostores";
2
+ import { deriveState } from "@clerk/shared/deriveState";
3
+ import { eventMethodCalled } from "@clerk/shared/telemetry";
4
+
5
+ //#region src/stores/internal.ts
6
+ const $csrState = map({
7
+ isLoaded: false,
8
+ client: void 0,
9
+ user: void 0,
10
+ session: void 0,
11
+ organization: void 0
12
+ });
13
+ const $initialState = map();
14
+ const $clerk = atom(null);
15
+
16
+ //#endregion
17
+ //#region src/stores/external.ts
18
+ /**
19
+ * A client side store that returns the loaded state of clerk-js.
20
+ *
21
+ * @example
22
+ * $isLoadedStore.subscribe((authloaded => console.log(loaded))
23
+ */
24
+ const $isLoadedStore = computed([$csrState], (state) => state.isLoaded);
25
+ /**
26
+ * A client side store that is prepopulated with the authentication context during SSR.
27
+ * It is a nanostore, for instructions on how to use nanostores please review the [documentation](https://github.com/nanostores/nanostores)
28
+ *
29
+ * @example
30
+ * $authStore.subscribe((auth) => console.log(auth.userId))
31
+ */
32
+ const $authStore = batched([$csrState, $initialState], (state, initialState) => {
33
+ return deriveState(state.isLoaded, {
34
+ session: state.session,
35
+ user: state.user,
36
+ organization: state.organization,
37
+ client: state.client
38
+ }, initialState);
39
+ });
40
+ /**
41
+ * A client side store that is populated after clerk-js has loaded.
42
+ * The store returns back the authenticated user or `null`.
43
+ * It is a nanostore, for instructions on how to use nanostores please review the [documentation](https://github.com/nanostores/nanostores)
44
+ *
45
+ * @example
46
+ * $userStore.subscribe((user) => console.log(user.id))
47
+ */
48
+ const $userStore = computed([$authStore], (auth) => auth.user);
49
+ /**
50
+ * A client side store that is populated after clerk-js has loaded.
51
+ * The store returns the session of the authenticated user or `null`.
52
+ * It is a nanostore, for instructions on how to use nanostores please review the [documentation](https://github.com/nanostores/nanostores)
53
+ *
54
+ * @example
55
+ * $sessionStore.subscribe((session) => console.log(session.id))
56
+ */
57
+ const $sessionStore = computed([$authStore], (auth) => auth.session);
58
+ /**
59
+ * A client side store that is populated after clerk-js has loaded.
60
+ * The store returns the Active Organization of the authenticated user or `null`.
61
+ * It is a nanostore, for instructions on how to use nanostores please review the [documentation](https://github.com/nanostores/nanostores)
62
+ *
63
+ * @example
64
+ * $organizationStore.subscribe((org) => console.log(org.id))
65
+ */
66
+ const $organizationStore = computed([$authStore], (auth) => auth.organization);
67
+ /**
68
+ * A client side store that is populated after clerk-js has loaded.
69
+ * The store returns the clerk client or `null`.
70
+ * It is a nanostore, for instructions on how to use nanostores please review the [documentation](https://github.com/nanostores/nanostores)
71
+ *
72
+ * @example
73
+ * $clientStore.subscribe((client) => console.log(client?.signedInSessions?.length))
74
+ */
75
+ const $clientStore = computed([$csrState], (csr) => csr.client);
76
+ /**
77
+ * A client side store that is populated after clerk-js is instanciated.
78
+ * The store returns the clerk instance or `null`.
79
+ * It is a nanostore, for instructions on how to use nanostores please review the [documentation](https://github.com/nanostores/nanostores)
80
+ *
81
+ * @example
82
+ * $clerkStore.subscribe((clerk) => console.log(clerk.publishableKey))
83
+ */
84
+ const $clerkStore = computed([$clerk], (clerk) => clerk);
85
+ /**
86
+ * A client side store that is populated after clerk-js has loaded.
87
+ * The store returns all the sessions of the current clerk client or `null`.
88
+ * It is a nanostore, for instructions on how to use nanostores please review the [documentation](https://github.com/nanostores/nanostores)
89
+ *
90
+ * @example
91
+ * $sessionListStore.subscribe((sessionList) => sessionList.map((session) => console.log('Session id:', sessino.id) ))
92
+ */
93
+ const $sessionListStore = computed([$clientStore], (client) => client?.sessions);
94
+ /**
95
+ * A client side store that is populated after clerk-js has loaded.
96
+ * The store returns a `SignInResource` or `null`.
97
+ * It is a nanostore, for instructions on how to use nanostores please review the [documentation](https://github.com/nanostores/nanostores)
98
+ *
99
+ * @example
100
+ * $signInStore.subscribe((signIn) => console.log(signIn.status))
101
+ */
102
+ const $signInStore = computed([$clientStore], (client) => client?.signIn);
103
+ /**
104
+ * A client side store that is populated after clerk-js has loaded.
105
+ * The store returns a `SignUpResource` or `null`.
106
+ * It is a nanostore, for instructions on how to use nanostores please review the [documentation](https://github.com/nanostores/nanostores)
107
+ *
108
+ * @example
109
+ * $signUpStore.subscribe((signUp) => console.log(signUp.status))
110
+ */
111
+ const $signUpStore = computed([$clientStore], (client) => client?.signUp);
112
+ /**
113
+ * A client side store that is populated after clerk-js has loaded.
114
+ * The store returns a `BillingNamespace` or `null`.
115
+ * It is a nanostore, for instructions on how to use nanostores please review the [documentation](https://github.com/nanostores/nanostores)
116
+ *
117
+ * @example
118
+ * $billingStore.subscribe((billing) => billing.getPlans().then((plans) => console.log(plans.data.length)))
119
+ */
120
+ const $billingStore = computed([$clerk], (clerk) => clerk?.billing);
121
+ /**
122
+ * Records a telemetry event when a store is used to match React hooks telemetry.
123
+ *
124
+ * @param {Store} store - The nanostore instance to monitor.
125
+ * @param {string} method - The name of the method associated with the store usage.
126
+ */
127
+ const recordTelemetryEvent = (store, method) => {
128
+ onMount(store, () => {
129
+ $clerk.get()?.telemetry?.record(eventMethodCalled(method));
130
+ });
131
+ };
132
+ recordTelemetryEvent($signInStore, "$signInStore");
133
+ recordTelemetryEvent($signUpStore, "$signUpStore");
134
+ recordTelemetryEvent($organizationStore, "$organizationStore");
135
+
136
+ //#endregion
137
+ export { $isLoadedStore as a, $sessionStore as c, $userStore as d, $clerk as f, $clientStore as i, $signInStore as l, $initialState as m, $billingStore as n, $organizationStore as o, $csrState as p, $clerkStore as r, $sessionListStore as s, $authStore as t, $signUpStore as u };
138
+ //# sourceMappingURL=external-DHTxQaok.js.map