@hexclave/next 1.0.25 → 1.0.27

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 (86) hide show
  1. package/dist/components/elements/ssr-layout-effect.d.ts.map +1 -1
  2. package/dist/components/elements/ssr-layout-effect.js +5 -3
  3. package/dist/components/elements/ssr-layout-effect.js.map +1 -1
  4. package/dist/components-page/hexclave-handler-client.js +5 -4
  5. package/dist/components-page/hexclave-handler-client.js.map +1 -1
  6. package/dist/dev-tool/dev-tool-core.js +1 -1
  7. package/dist/dev-tool/dev-tool-core.js.map +1 -1
  8. package/dist/esm/components/elements/ssr-layout-effect.d.ts.map +1 -1
  9. package/dist/esm/components/elements/ssr-layout-effect.js +5 -3
  10. package/dist/esm/components/elements/ssr-layout-effect.js.map +1 -1
  11. package/dist/esm/components-page/hexclave-handler-client.js +5 -4
  12. package/dist/esm/components-page/hexclave-handler-client.js.map +1 -1
  13. package/dist/esm/dev-tool/dev-tool-core.js +1 -1
  14. package/dist/esm/dev-tool/dev-tool-core.js.map +1 -1
  15. package/dist/esm/generated/quetzal-translations.d.ts +2 -2
  16. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +7 -0
  17. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
  18. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.js +33 -1
  19. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.js.map +1 -1
  20. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +1 -0
  21. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts.map +1 -1
  22. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js +9 -8
  23. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
  24. package/dist/esm/lib/hexclave-app/apps/implementations/common.js +1 -1
  25. package/dist/esm/lib/hexclave-app/apps/implementations/session-replay.d.ts +1 -0
  26. package/dist/esm/lib/hexclave-app/apps/implementations/session-replay.d.ts.map +1 -1
  27. package/dist/esm/lib/hexclave-app/apps/implementations/session-replay.js +44 -19
  28. package/dist/esm/lib/hexclave-app/apps/implementations/session-replay.js.map +1 -1
  29. package/dist/esm/lib/hexclave-app/apps/implementations/session-replay.test.js +97 -8
  30. package/dist/esm/lib/hexclave-app/apps/implementations/session-replay.test.js.map +1 -1
  31. package/dist/esm/lib/hexclave-app/apps/interfaces/admin-app.d.ts +2 -1
  32. package/dist/esm/lib/hexclave-app/apps/interfaces/admin-app.d.ts.map +1 -1
  33. package/dist/esm/lib/hexclave-app/apps/interfaces/admin-app.js.map +1 -1
  34. package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.d.ts +1 -0
  35. package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.d.ts.map +1 -1
  36. package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.js.map +1 -1
  37. package/dist/esm/lib/hexclave-app/index.d.ts +2 -1
  38. package/dist/esm/lib/hexclave-app/plan-usage/index.d.ts +27 -0
  39. package/dist/esm/lib/hexclave-app/plan-usage/index.d.ts.map +1 -0
  40. package/dist/esm/lib/hexclave-app/plan-usage/index.js +1 -0
  41. package/dist/esm/lib/hexclave-app/projects/index.d.ts +1 -0
  42. package/dist/esm/lib/hexclave-app/projects/index.d.ts.map +1 -1
  43. package/dist/esm/lib/hexclave-app/projects/index.js.map +1 -1
  44. package/dist/generated/quetzal-translations.d.ts +2 -2
  45. package/dist/index.d.ts +2 -1
  46. package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +7 -0
  47. package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
  48. package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.js +33 -1
  49. package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.js.map +1 -1
  50. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +1 -0
  51. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.d.ts.map +1 -1
  52. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js +9 -8
  53. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
  54. package/dist/lib/hexclave-app/apps/implementations/common.js +1 -1
  55. package/dist/lib/hexclave-app/apps/implementations/session-replay.d.ts +1 -0
  56. package/dist/lib/hexclave-app/apps/implementations/session-replay.d.ts.map +1 -1
  57. package/dist/lib/hexclave-app/apps/implementations/session-replay.js +43 -18
  58. package/dist/lib/hexclave-app/apps/implementations/session-replay.js.map +1 -1
  59. package/dist/lib/hexclave-app/apps/implementations/session-replay.test.js +97 -8
  60. package/dist/lib/hexclave-app/apps/implementations/session-replay.test.js.map +1 -1
  61. package/dist/lib/hexclave-app/apps/interfaces/admin-app.d.ts +2 -1
  62. package/dist/lib/hexclave-app/apps/interfaces/admin-app.d.ts.map +1 -1
  63. package/dist/lib/hexclave-app/apps/interfaces/admin-app.js.map +1 -1
  64. package/dist/lib/hexclave-app/apps/interfaces/client-app.d.ts +1 -0
  65. package/dist/lib/hexclave-app/apps/interfaces/client-app.d.ts.map +1 -1
  66. package/dist/lib/hexclave-app/apps/interfaces/client-app.js.map +1 -1
  67. package/dist/lib/hexclave-app/index.d.ts +2 -1
  68. package/dist/lib/hexclave-app/plan-usage/index.d.ts +27 -0
  69. package/dist/lib/hexclave-app/plan-usage/index.d.ts.map +1 -0
  70. package/dist/lib/hexclave-app/plan-usage/index.js +0 -0
  71. package/dist/lib/hexclave-app/projects/index.d.ts +1 -0
  72. package/dist/lib/hexclave-app/projects/index.d.ts.map +1 -1
  73. package/dist/lib/hexclave-app/projects/index.js.map +1 -1
  74. package/package.json +4 -4
  75. package/src/components/elements/ssr-layout-effect.tsx +15 -3
  76. package/src/components-page/hexclave-handler-client.tsx +5 -4
  77. package/src/dev-tool/dev-tool-core.ts +1 -1
  78. package/src/lib/hexclave-app/apps/implementations/admin-app-impl.ts +38 -1
  79. package/src/lib/hexclave-app/apps/implementations/client-app-impl.ts +9 -8
  80. package/src/lib/hexclave-app/apps/implementations/session-replay.test.ts +123 -4
  81. package/src/lib/hexclave-app/apps/implementations/session-replay.ts +63 -29
  82. package/src/lib/hexclave-app/apps/interfaces/admin-app.ts +2 -0
  83. package/src/lib/hexclave-app/apps/interfaces/client-app.ts +1 -0
  84. package/src/lib/hexclave-app/index.ts +8 -0
  85. package/src/lib/hexclave-app/plan-usage/index.ts +29 -0
  86. package/src/lib/hexclave-app/projects/index.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ssr-layout-effect.d.ts","names":[],"sources":["../../../../src/components/elements/ssr-layout-effect.tsx"],"mappings":";;;iBAQgB,SAAA,CAAU,KAAA;EAAS,MAAA;EAAgB,KAAA;AAAA,IAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
1
+ {"version":3,"file":"ssr-layout-effect.d.ts","names":[],"sources":["../../../../src/components/elements/ssr-layout-effect.tsx"],"mappings":";;;iBAYgB,SAAA,CAAU,KAAA;EAAS,MAAA;EAAgB,KAAA;AAAA,IAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -4,14 +4,16 @@ import { useLayoutEffect } from "react";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
 
6
6
  //#region src/components/elements/ssr-layout-effect.tsx
7
+ function escapeHtmlAttr(str) {
8
+ return str.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
9
+ }
7
10
  function SsrScript(props) {
8
11
  useLayoutEffect(() => {
9
12
  (0, eval)(props.script);
10
13
  }, []);
11
- return /* @__PURE__ */ jsx("script", {
14
+ return /* @__PURE__ */ jsx("span", {
12
15
  suppressHydrationWarning: true,
13
- nonce: props.nonce,
14
- dangerouslySetInnerHTML: { __html: props.script }
16
+ dangerouslySetInnerHTML: { __html: `<script${props.nonce ? ` nonce="${escapeHtmlAttr(props.nonce)}"` : ""}>${props.script}<\/script>` }
15
17
  });
16
18
  }
17
19
 
@@ -1 +1 @@
1
- {"version":3,"file":"ssr-layout-effect.js","names":[],"sources":["../../../../src/components/elements/ssr-layout-effect.tsx"],"sourcesContent":["\"use client\";\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\nimport { useLayoutEffect } from \"react\";\n\nexport function SsrScript(props: { script: string, nonce?: string }) {\n useLayoutEffect(() => {\n // TODO fix workaround: React has a bug where it doesn't run the script on the first CSR render if SSR has been skipped due to suspense\n // As a workaround, we run the script in the <script> tag again after the first render\n // Note that we do an indirect eval as described here: https://esbuild.github.io/content-types/#direct-eval\n (0, eval)(props.script);\n }, []);\n\n return (\n <script\n suppressHydrationWarning // the transpiler is setup differently for client/server targets, so if `script` was generated with Function.toString they will differ\n nonce={props.nonce}\n dangerouslySetInnerHTML={{ __html: props.script }}\n />\n );\n}\n"],"mappings":";;;;;;AAQA,SAAgB,UAAU,OAA2C;AACnE,uBAAsB;AAIpB,GAAC,GAAG,MAAM,MAAM,OAAO;IACtB,EAAE,CAAC;AAEN,QACE,oBAAC;EACC;EACA,OAAO,MAAM;EACb,yBAAyB,EAAE,QAAQ,MAAM,QAAQ;GACjD"}
1
+ {"version":3,"file":"ssr-layout-effect.js","names":[],"sources":["../../../../src/components/elements/ssr-layout-effect.tsx"],"sourcesContent":["\"use client\";\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\nimport { useLayoutEffect } from \"react\";\n\nfunction escapeHtmlAttr(str: string): string {\n return str.replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n}\n\nexport function SsrScript(props: { script: string, nonce?: string }) {\n useLayoutEffect(() => {\n // TODO fix workaround: React has a bug where it doesn't run the script on the first CSR render if SSR has been skipped due to suspense\n // As a workaround, we run the script in the <script> tag again after the first render\n // Note that we do an indirect eval as described here: https://esbuild.github.io/content-types/#direct-eval\n (0, eval)(props.script);\n }, []);\n\n // Embed the <script> in a span's innerHTML rather than as a React <script> JSX element to\n // avoid React 19's \"Scripts inside React components are never executed when rendering on the\n // client\" warning. The browser still executes the script during SSR HTML parsing, and on the\n // client React sets innerHTML but the browser won't re-execute the script (innerHTML scripts\n // don't run). Using the same HTML on both sides avoids hydration mismatches.\n const nonceAttr = props.nonce ? ` nonce=\"${escapeHtmlAttr(props.nonce)}\"` : '';\n\n return (\n <span\n suppressHydrationWarning // the transpiler is setup differently for client/server targets, so if `script` was generated with Function.toString they will differ\n dangerouslySetInnerHTML={{\n __html: `<script${nonceAttr}>${props.script}</script>`,\n }}\n />\n );\n}\n"],"mappings":";;;;;;AAQA,SAAS,eAAe,KAAqB;AAC3C,QAAO,IAAI,QAAQ,MAAM,QAAQ,CAAC,QAAQ,MAAM,SAAS,CAAC,QAAQ,MAAM,OAAO,CAAC,QAAQ,MAAM,OAAO;;AAGvG,SAAgB,UAAU,OAA2C;AACnE,uBAAsB;AAIpB,GAAC,GAAG,MAAM,MAAM,OAAO;IACtB,EAAE,CAAC;AASN,QACE,oBAAC;EACC;EACA,yBAAyB,EACvB,QAAQ,UANI,MAAM,QAAQ,WAAW,eAAe,MAAM,MAAM,CAAC,KAAK,GAM1C,GAAG,MAAM,OAAO,aAC7C;GACD"}
@@ -143,7 +143,7 @@ function renderComponent(props) {
143
143
  });
144
144
  default: {
145
145
  if (Object.values(availablePaths).includes(path)) throw new HexclaveAssertionError(`Path alias ${path} not included in switch statement, but in availablePaths?`, { availablePaths });
146
- for (const [key, value] of Object.entries(pathAliases)) if (path.toLowerCase().replaceAll("-", "") === key.toLowerCase().replaceAll("-", "")) return { redirect: `${app.urls.handler}/${value}?${new URLSearchParams(searchParams).toString()}` };
146
+ for (const [key, value] of Object.entries(pathAliases)) if (path.toLowerCase().replaceAll("-", "") === key.toLowerCase().replaceAll("-", "")) return { redirect: `${app[hexclaveAppInternalsSymbol].getUrls().handler}/${value}?${new URLSearchParams(searchParams).toString()}` };
147
147
  const defaultUnknownPathUrl = getDefaultUnknownPathUrl?.(path);
148
148
  if (defaultUnknownPathUrl != null) {
149
149
  const defaultUnknownPathUrlObject = new URL(defaultUnknownPathUrl, "http://example.com");
@@ -184,13 +184,14 @@ function RedirectToPage(props) {
184
184
  }
185
185
  function HexclaveHandlerClient(props) {
186
186
  const hexclaveApp = useStackApp$1();
187
+ const handlerUrls = hexclaveApp[hexclaveAppInternalsSymbol].getUrls();
187
188
  const clientOrigin = useClientOriginAfterHydration();
188
189
  const pathname = usePathname();
189
190
  const searchParamsFromHook = useSearchParams();
190
191
  const currentLocation = pathname;
191
192
  const searchParamsSource = searchParamsFromHook;
192
193
  const { path, searchParams, handlerPath } = useMemo(() => {
193
- const handlerPath = new URL(hexclaveApp.urls.handler, "http://example.com").pathname;
194
+ const handlerPath = new URL(handlerUrls.handler, "http://example.com").pathname;
194
195
  return {
195
196
  path: currentLocation.startsWith(handlerPath) ? currentLocation.slice(handlerPath.length).replace(/^\/+/, "") : currentLocation.replace(/^\/+/, ""),
196
197
  searchParams: Object.fromEntries(searchParamsSource.entries()),
@@ -199,7 +200,7 @@ function HexclaveHandlerClient(props) {
199
200
  }, [
200
201
  currentLocation,
201
202
  searchParamsSource,
202
- hexclaveApp.urls.handler
203
+ handlerUrls.handler
203
204
  ]);
204
205
  const getDefaultUnknownPathUrl = (unknownPath) => {
205
206
  return resolveUnknownHandlerPathFallbackUrl({
@@ -209,7 +210,7 @@ function HexclaveHandlerClient(props) {
209
210
  });
210
211
  };
211
212
  const shouldRedirectToPage = (name) => {
212
- const url = hexclaveApp.urls[name];
213
+ const url = handlerUrls[name];
213
214
  if (name === "oauthCallback" && searchParams.hexclave_cross_domain_auth === "1") return false;
214
215
  return !isLocalHandlerUrlTarget({
215
216
  targetUrl: url,
@@ -1 +1 @@
1
- {"version":3,"file":"hexclave-handler-client.js","names":["MessageCard","useStackApp"],"sources":["../../../src/components-page/hexclave-handler-client.tsx"],"sourcesContent":["\"use client\";\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { KnownError } from \"@hexclave/shared\";\nimport { captureError, HexclaveAssertionError } from \"@hexclave/shared/dist/utils/errors\";\nimport { FilterUndefined, filterUndefined } from \"@hexclave/shared/dist/utils/objects\";\nimport { use } from \"@hexclave/shared/dist/utils/react\";\nimport { getRelativePart } from \"@hexclave/shared/dist/utils/urls\";\nimport { notFound, redirect, RedirectType, usePathname, useSearchParams } from 'next/navigation'; // THIS_LINE_PLATFORM next\nimport { Suspense, useMemo, useSyncExternalStore } from 'react';\nimport { SignIn, SignUp, StackServerApp } from \"..\";\nimport { useStackApp } from \"../lib/hooks\";\nimport { HandlerUrls, StackClientApp, hexclaveAppInternalsSymbol } from \"../lib/hexclave-app\";\nimport { isLocalHandlerUrlTarget, resolveUnknownHandlerPathFallbackUrl } from \"../lib/hexclave-app/url-targets\";\nimport { AccountSettings } from \"./account-settings\";\nimport { CliAuthConfirmation } from \"./cli-auth-confirm\";\nimport { EmailVerification } from \"./email-verification\";\nimport { ErrorPage } from \"./error-page\";\nimport { ForgotPassword } from \"./forgot-password\";\nimport { MagicLinkCallback } from \"./magic-link-callback\";\nimport { MFA } from \"./mfa\";\nimport { OAuthCallback } from \"./oauth-callback\";\nimport { Onboarding } from \"./onboarding\";\nimport { PasswordReset } from \"./password-reset\";\nimport { SignOut } from \"./sign-out\";\nimport { TeamInvitation } from \"./team-invitation\";\n\nimport { KnownErrorMessageCard } from \"../components/message-cards/known-error-message-card\";\nimport { MessageCard } from \"../components/message-cards/message-card\";\nimport { PredefinedMessageCard } from \"../components/message-cards/predefined-message-card\";\n\ntype Components = {\n SignIn: typeof SignIn,\n SignUp: typeof SignUp,\n EmailVerification: typeof EmailVerification,\n PasswordReset: typeof PasswordReset,\n ForgotPassword: typeof ForgotPassword,\n SignOut: typeof SignOut,\n OAuthCallback: typeof OAuthCallback,\n MagicLinkCallback: typeof MagicLinkCallback,\n TeamInvitation: typeof TeamInvitation,\n ErrorPage: typeof ErrorPage,\n AccountSettings: typeof AccountSettings,\n CliAuthConfirmation: typeof CliAuthConfirmation,\n MFA: typeof MFA,\n Onboarding: typeof Onboarding,\n};\n\ntype RouteProps = {\n params: Promise<{ stack?: string[] }> | { stack?: string[] },\n searchParams: Promise<Record<string, string>> | Record<string, string>,\n};\n\ntype RedirectToPageResult =\n | { status: \"success\" }\n | { status: \"known-error\", error: KnownError }\n | { status: \"unknown-error\" };\n\nconst availablePaths = {\n signIn: 'sign-in',\n signUp: 'sign-up',\n emailVerification: 'email-verification',\n passwordReset: 'password-reset',\n forgotPassword: 'forgot-password',\n signOut: 'sign-out',\n oauthCallback: 'oauth-callback',\n magicLinkCallback: 'magic-link-callback',\n teamInvitation: 'team-invitation',\n accountSettings: 'account-settings',\n cliAuthConfirm: 'cli-auth-confirm',\n mfa: 'mfa',\n error: 'error',\n onboarding: 'onboarding',\n} as const;\n\nconst placeholderOrigin = \"http://example.com\";\n\nconst pathAliases = {\n // also includes the uppercase and non-dashed versions\n ...Object.fromEntries(Object.entries(availablePaths).map(([key, value]) => [value, value])),\n \"log-in\": availablePaths.signIn,\n \"register\": availablePaths.signUp,\n} as const;\n\nexport type BaseHandlerProps = {\n fullPage: boolean,\n componentProps?: {\n [K in keyof Components]?: Parameters<Components[K]>[0];\n },\n};\n\nfunction renderComponent(props: {\n path: string,\n searchParams: Record<string, string>,\n fullPage: boolean,\n componentProps?: BaseHandlerProps['componentProps'],\n shouldRedirectToPage?: (name: keyof HandlerUrls) => boolean,\n getDefaultUnknownPathUrl?: (path: string) => string | null,\n onNotFound: () => any,\n app: StackClientApp<any> | StackServerApp<any>,\n}) {\n const { path, searchParams, fullPage, componentProps, shouldRedirectToPage, getDefaultUnknownPathUrl, onNotFound, app } = props;\n\n switch (path) {\n case availablePaths.signIn: {\n if (shouldRedirectToPage?.('signIn')) return { redirectToPage: 'signIn' as const };\n return <SignIn\n fullPage={fullPage}\n automaticRedirect\n {...filterUndefinedINU(componentProps?.SignIn)}\n />;\n }\n case availablePaths.signUp: {\n if (shouldRedirectToPage?.('signUp')) return { redirectToPage: 'signUp' as const };\n return <SignUp\n fullPage={fullPage}\n automaticRedirect\n {...filterUndefinedINU(componentProps?.SignUp)}\n />;\n }\n case availablePaths.emailVerification: {\n if (shouldRedirectToPage?.('emailVerification')) return { redirectToPage: 'emailVerification' as const };\n return <EmailVerification\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.EmailVerification)}\n />;\n }\n case availablePaths.passwordReset: {\n if (shouldRedirectToPage?.('passwordReset')) return { redirectToPage: 'passwordReset' as const };\n return <PasswordReset\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.PasswordReset)}\n />;\n }\n case availablePaths.forgotPassword: {\n if (shouldRedirectToPage?.('forgotPassword')) return { redirectToPage: 'forgotPassword' as const };\n return <ForgotPassword\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.ForgotPassword)}\n />;\n }\n case availablePaths.signOut: {\n if (shouldRedirectToPage?.('signOut')) return { redirectToPage: 'signOut' as const };\n return <SignOut\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.SignOut)}\n />;\n }\n case availablePaths.oauthCallback: {\n if (shouldRedirectToPage?.('oauthCallback')) return { redirectToPage: 'oauthCallback' as const };\n return <OAuthCallback\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.OAuthCallback)}\n />;\n }\n case availablePaths.magicLinkCallback: {\n if (shouldRedirectToPage?.('magicLinkCallback')) return { redirectToPage: 'magicLinkCallback' as const };\n return <MagicLinkCallback\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.MagicLinkCallback)}\n />;\n }\n case availablePaths.teamInvitation: {\n if (shouldRedirectToPage?.('teamInvitation')) return { redirectToPage: 'teamInvitation' as const };\n return <TeamInvitation\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.TeamInvitation)}\n />;\n }\n case availablePaths.accountSettings: {\n return <AccountSettings\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.AccountSettings)}\n />;\n }\n case availablePaths.error: {\n return <ErrorPage\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.ErrorPage)}\n />;\n }\n case availablePaths.cliAuthConfirm: {\n if (shouldRedirectToPage?.('cliAuthConfirm')) return { redirectToPage: 'cliAuthConfirm' as const };\n return <CliAuthConfirmation\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.CliAuthConfirmation)}\n />;\n }\n case availablePaths.mfa: {\n if (shouldRedirectToPage?.('mfa')) return { redirectToPage: 'mfa' as const };\n return <MFA\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.MFA)}\n />;\n }\n case availablePaths.onboarding: {\n if (shouldRedirectToPage?.('onboarding')) return { redirectToPage: 'onboarding' as const };\n return <Onboarding\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.Onboarding)}\n />;\n }\n default: {\n if (Object.values(availablePaths).includes(path as any)) {\n throw new HexclaveAssertionError(`Path alias ${path} not included in switch statement, but in availablePaths?`, { availablePaths });\n }\n for (const [key, value] of Object.entries(pathAliases)) {\n if (path.toLowerCase().replaceAll('-', '') === key.toLowerCase().replaceAll('-', '')) {\n const redirectUrl = `${app.urls.handler}/${value}?${new URLSearchParams(searchParams).toString()}`;\n return { redirect: redirectUrl };\n }\n }\n const defaultUnknownPathUrl = getDefaultUnknownPathUrl?.(path);\n if (defaultUnknownPathUrl != null) {\n const defaultUnknownPathUrlObject = new URL(defaultUnknownPathUrl, \"http://example.com\");\n for (const [key, value] of Object.entries(searchParams)) {\n defaultUnknownPathUrlObject.searchParams.set(key, value);\n }\n return { redirect: toAbsoluteOrRelativeRedirectTarget(defaultUnknownPathUrlObject) };\n }\n return onNotFound();\n }\n }\n}\n\nexport async function getRedirectToPageResult(\n app: StackClientApp,\n redirectToPage: keyof HandlerUrls,\n): Promise<RedirectToPageResult> {\n try {\n await app[hexclaveAppInternalsSymbol].redirectToHandler(redirectToPage, { replace: true });\n return { status: \"success\" };\n } catch (e) {\n if (KnownError.isKnownError(e)) {\n return { status: \"known-error\", error: e };\n }\n captureError(\"<HexclaveHandlerClient redirectToPage />\", e);\n return { status: \"unknown-error\" };\n }\n}\n\nfunction RedirectToPage(props: {\n app: StackClientApp,\n fullPage?: boolean,\n redirectToPage: keyof HandlerUrls,\n}) {\n const redirectResultPromise = useMemo(\n () => getRedirectToPageResult(props.app, props.redirectToPage),\n [props.app, props.redirectToPage],\n );\n\n const redirectResult = use(redirectResultPromise);\n if (redirectResult.status === \"known-error\") {\n return <KnownErrorMessageCard error={redirectResult.error} fullPage={props.fullPage} />;\n }\n if (redirectResult.status === \"unknown-error\") {\n return <PredefinedMessageCard type=\"unknownError\" fullPage={props.fullPage} />;\n }\n return <MessageCard title=\"Redirecting...\" fullPage={props.fullPage} />;\n}\n\nexport function HexclaveHandlerClient(props: BaseHandlerProps & Partial<RouteProps> & { location?: string }) {\n // Use hooks to get app\n const hexclaveApp = useStackApp();\n const clientOrigin = useClientOriginAfterHydration();\n\n const pathname = usePathname();\n const searchParamsFromHook = useSearchParams();\n const currentLocation = pathname;\n const searchParamsSource = searchParamsFromHook;\n\n const { path, searchParams, handlerPath } = useMemo(() => {\n const handlerPath = new URL(hexclaveApp.urls.handler, 'http://example.com').pathname;\n const relativePath = currentLocation.startsWith(handlerPath)\n ? currentLocation.slice(handlerPath.length).replace(/^\\/+/, '')\n : currentLocation.replace(/^\\/+/, '');\n\n return {\n path: relativePath,\n searchParams: Object.fromEntries(searchParamsSource.entries()),\n handlerPath,\n };\n }, [currentLocation, searchParamsSource, hexclaveApp.urls.handler]);\n\n const getDefaultUnknownPathUrl = (unknownPath: string): string | null => {\n return resolveUnknownHandlerPathFallbackUrl({\n defaultTarget: hexclaveApp[hexclaveAppInternalsSymbol].getConstructorOptions().urls?.default,\n projectId: hexclaveApp.projectId,\n unknownPath,\n });\n };\n\n const shouldRedirectToPage = (name: keyof HandlerUrls): boolean => {\n const url = hexclaveApp.urls[name];\n const isCrossDomainLocalOauthCallback = name === \"oauthCallback\" && searchParams.hexclave_cross_domain_auth === \"1\";\n if (isCrossDomainLocalOauthCallback) {\n return false;\n }\n return !isLocalHandlerUrlTarget({\n targetUrl: url,\n handlerPath,\n currentOrigin: clientOrigin,\n });\n };\n\n const result = renderComponent({\n path,\n searchParams,\n fullPage: props.fullPage,\n componentProps: props.componentProps,\n shouldRedirectToPage,\n getDefaultUnknownPathUrl,\n onNotFound: () =>\n notFound()\n ,\n app: hexclaveApp,\n });\n\n const redirectToPage = (result != null && typeof result === 'object' && 'redirectToPage' in result) ? result.redirectToPage : undefined;\n\n if (redirectToPage != null) {\n return (\n <Suspense fallback={<MessageCard title=\"Redirecting...\" fullPage={props.fullPage} />}>\n <RedirectToPage app={hexclaveApp} redirectToPage={redirectToPage} fullPage={props.fullPage} />\n </Suspense>\n );\n }\n\n if (result && 'redirect' in result) {\n redirect(result.redirect, RedirectType.replace);\n }\n\n\n return result;\n}\n\n// filter undefined values in object. if object itself is undefined, return undefined\nfunction filterUndefinedINU<T extends {}>(value: T | undefined): FilterUndefined<T> | undefined {\n return value === undefined ? value : filterUndefined(value);\n}\n\nfunction toAbsoluteOrRelativeRedirectTarget(url: URL): string {\n return url.origin === \"http://example.com\" ? getRelativePart(url) : url.toString();\n}\n\nfunction useClientOriginAfterHydration(): string | undefined {\n // The first hydrated render must match SSR. After hydration, React re-checks\n // the snapshot and lets us distinguish same-path cross-origin handler URLs.\n return useSyncExternalStore(\n () => () => {},\n () => window.location.origin,\n () => undefined,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,MAAM,iBAAiB;CACrB,QA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BAAC;GAAe,KAAK;GAA6B;GAAgB,UAAU,MAAM;IAAY;GACrF;AAIf,KAAI,UAAU,cAAc,OAC1B,UAAS,OAAO,UAAU,aAAa,QAAQ;AAIjD,QAAO;;AAIT,SAAS,mBAAiC,OAAsD;AAC9F,QAAO,UAAU,SAAY,QAAQ,gBAAgB,MAAM;;AAG7D,SAAS,mCAAmC,KAAkB;AAC5D,QAAO,IAAI,WAAW,uBAAuB,gBAAgB,IAAI,GAAG,IAAI,UAAU;;AAGpF,SAAS,gCAAoD;AAG3D,QAAO,iCACO,UACN,OAAO,SAAS,cAChB,OACP"}
1
+ {"version":3,"file":"hexclave-handler-client.js","names":["MessageCard","useStackApp"],"sources":["../../../src/components-page/hexclave-handler-client.tsx"],"sourcesContent":["\"use client\";\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { KnownError } from \"@hexclave/shared\";\nimport { captureError, HexclaveAssertionError } from \"@hexclave/shared/dist/utils/errors\";\nimport { FilterUndefined, filterUndefined } from \"@hexclave/shared/dist/utils/objects\";\nimport { use } from \"@hexclave/shared/dist/utils/react\";\nimport { getRelativePart } from \"@hexclave/shared/dist/utils/urls\";\nimport { notFound, redirect, RedirectType, usePathname, useSearchParams } from 'next/navigation'; // THIS_LINE_PLATFORM next\nimport { Suspense, useMemo, useSyncExternalStore } from 'react';\nimport { SignIn, SignUp, StackServerApp } from \"..\";\nimport { useStackApp } from \"../lib/hooks\";\nimport { HandlerUrls, StackClientApp, hexclaveAppInternalsSymbol } from \"../lib/hexclave-app\";\nimport { isLocalHandlerUrlTarget, resolveUnknownHandlerPathFallbackUrl } from \"../lib/hexclave-app/url-targets\";\nimport { AccountSettings } from \"./account-settings\";\nimport { CliAuthConfirmation } from \"./cli-auth-confirm\";\nimport { EmailVerification } from \"./email-verification\";\nimport { ErrorPage } from \"./error-page\";\nimport { ForgotPassword } from \"./forgot-password\";\nimport { MagicLinkCallback } from \"./magic-link-callback\";\nimport { MFA } from \"./mfa\";\nimport { OAuthCallback } from \"./oauth-callback\";\nimport { Onboarding } from \"./onboarding\";\nimport { PasswordReset } from \"./password-reset\";\nimport { SignOut } from \"./sign-out\";\nimport { TeamInvitation } from \"./team-invitation\";\n\nimport { KnownErrorMessageCard } from \"../components/message-cards/known-error-message-card\";\nimport { MessageCard } from \"../components/message-cards/message-card\";\nimport { PredefinedMessageCard } from \"../components/message-cards/predefined-message-card\";\n\ntype Components = {\n SignIn: typeof SignIn,\n SignUp: typeof SignUp,\n EmailVerification: typeof EmailVerification,\n PasswordReset: typeof PasswordReset,\n ForgotPassword: typeof ForgotPassword,\n SignOut: typeof SignOut,\n OAuthCallback: typeof OAuthCallback,\n MagicLinkCallback: typeof MagicLinkCallback,\n TeamInvitation: typeof TeamInvitation,\n ErrorPage: typeof ErrorPage,\n AccountSettings: typeof AccountSettings,\n CliAuthConfirmation: typeof CliAuthConfirmation,\n MFA: typeof MFA,\n Onboarding: typeof Onboarding,\n};\n\ntype RouteProps = {\n params: Promise<{ stack?: string[] }> | { stack?: string[] },\n searchParams: Promise<Record<string, string>> | Record<string, string>,\n};\n\ntype RedirectToPageResult =\n | { status: \"success\" }\n | { status: \"known-error\", error: KnownError }\n | { status: \"unknown-error\" };\n\nconst availablePaths = {\n signIn: 'sign-in',\n signUp: 'sign-up',\n emailVerification: 'email-verification',\n passwordReset: 'password-reset',\n forgotPassword: 'forgot-password',\n signOut: 'sign-out',\n oauthCallback: 'oauth-callback',\n magicLinkCallback: 'magic-link-callback',\n teamInvitation: 'team-invitation',\n accountSettings: 'account-settings',\n cliAuthConfirm: 'cli-auth-confirm',\n mfa: 'mfa',\n error: 'error',\n onboarding: 'onboarding',\n} as const;\n\nconst placeholderOrigin = \"http://example.com\";\n\nconst pathAliases = {\n // also includes the uppercase and non-dashed versions\n ...Object.fromEntries(Object.entries(availablePaths).map(([key, value]) => [value, value])),\n \"log-in\": availablePaths.signIn,\n \"register\": availablePaths.signUp,\n} as const;\n\nexport type BaseHandlerProps = {\n fullPage: boolean,\n componentProps?: {\n [K in keyof Components]?: Parameters<Components[K]>[0];\n },\n};\n\nfunction renderComponent(props: {\n path: string,\n searchParams: Record<string, string>,\n fullPage: boolean,\n componentProps?: BaseHandlerProps['componentProps'],\n shouldRedirectToPage?: (name: keyof HandlerUrls) => boolean,\n getDefaultUnknownPathUrl?: (path: string) => string | null,\n onNotFound: () => any,\n app: StackClientApp<any> | StackServerApp<any>,\n}) {\n const { path, searchParams, fullPage, componentProps, shouldRedirectToPage, getDefaultUnknownPathUrl, onNotFound, app } = props;\n\n switch (path) {\n case availablePaths.signIn: {\n if (shouldRedirectToPage?.('signIn')) return { redirectToPage: 'signIn' as const };\n return <SignIn\n fullPage={fullPage}\n automaticRedirect\n {...filterUndefinedINU(componentProps?.SignIn)}\n />;\n }\n case availablePaths.signUp: {\n if (shouldRedirectToPage?.('signUp')) return { redirectToPage: 'signUp' as const };\n return <SignUp\n fullPage={fullPage}\n automaticRedirect\n {...filterUndefinedINU(componentProps?.SignUp)}\n />;\n }\n case availablePaths.emailVerification: {\n if (shouldRedirectToPage?.('emailVerification')) return { redirectToPage: 'emailVerification' as const };\n return <EmailVerification\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.EmailVerification)}\n />;\n }\n case availablePaths.passwordReset: {\n if (shouldRedirectToPage?.('passwordReset')) return { redirectToPage: 'passwordReset' as const };\n return <PasswordReset\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.PasswordReset)}\n />;\n }\n case availablePaths.forgotPassword: {\n if (shouldRedirectToPage?.('forgotPassword')) return { redirectToPage: 'forgotPassword' as const };\n return <ForgotPassword\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.ForgotPassword)}\n />;\n }\n case availablePaths.signOut: {\n if (shouldRedirectToPage?.('signOut')) return { redirectToPage: 'signOut' as const };\n return <SignOut\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.SignOut)}\n />;\n }\n case availablePaths.oauthCallback: {\n if (shouldRedirectToPage?.('oauthCallback')) return { redirectToPage: 'oauthCallback' as const };\n return <OAuthCallback\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.OAuthCallback)}\n />;\n }\n case availablePaths.magicLinkCallback: {\n if (shouldRedirectToPage?.('magicLinkCallback')) return { redirectToPage: 'magicLinkCallback' as const };\n return <MagicLinkCallback\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.MagicLinkCallback)}\n />;\n }\n case availablePaths.teamInvitation: {\n if (shouldRedirectToPage?.('teamInvitation')) return { redirectToPage: 'teamInvitation' as const };\n return <TeamInvitation\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.TeamInvitation)}\n />;\n }\n case availablePaths.accountSettings: {\n return <AccountSettings\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.AccountSettings)}\n />;\n }\n case availablePaths.error: {\n return <ErrorPage\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.ErrorPage)}\n />;\n }\n case availablePaths.cliAuthConfirm: {\n if (shouldRedirectToPage?.('cliAuthConfirm')) return { redirectToPage: 'cliAuthConfirm' as const };\n return <CliAuthConfirmation\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.CliAuthConfirmation)}\n />;\n }\n case availablePaths.mfa: {\n if (shouldRedirectToPage?.('mfa')) return { redirectToPage: 'mfa' as const };\n return <MFA\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.MFA)}\n />;\n }\n case availablePaths.onboarding: {\n if (shouldRedirectToPage?.('onboarding')) return { redirectToPage: 'onboarding' as const };\n return <Onboarding\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.Onboarding)}\n />;\n }\n default: {\n if (Object.values(availablePaths).includes(path as any)) {\n throw new HexclaveAssertionError(`Path alias ${path} not included in switch statement, but in availablePaths?`, { availablePaths });\n }\n for (const [key, value] of Object.entries(pathAliases)) {\n if (path.toLowerCase().replaceAll('-', '') === key.toLowerCase().replaceAll('-', '')) {\n const redirectUrl = `${app[hexclaveAppInternalsSymbol].getUrls().handler}/${value}?${new URLSearchParams(searchParams).toString()}`;\n return { redirect: redirectUrl };\n }\n }\n const defaultUnknownPathUrl = getDefaultUnknownPathUrl?.(path);\n if (defaultUnknownPathUrl != null) {\n const defaultUnknownPathUrlObject = new URL(defaultUnknownPathUrl, \"http://example.com\");\n for (const [key, value] of Object.entries(searchParams)) {\n defaultUnknownPathUrlObject.searchParams.set(key, value);\n }\n return { redirect: toAbsoluteOrRelativeRedirectTarget(defaultUnknownPathUrlObject) };\n }\n return onNotFound();\n }\n }\n}\n\nexport async function getRedirectToPageResult(\n app: StackClientApp,\n redirectToPage: keyof HandlerUrls,\n): Promise<RedirectToPageResult> {\n try {\n await app[hexclaveAppInternalsSymbol].redirectToHandler(redirectToPage, { replace: true });\n return { status: \"success\" };\n } catch (e) {\n if (KnownError.isKnownError(e)) {\n return { status: \"known-error\", error: e };\n }\n captureError(\"<HexclaveHandlerClient redirectToPage />\", e);\n return { status: \"unknown-error\" };\n }\n}\n\nfunction RedirectToPage(props: {\n app: StackClientApp,\n fullPage?: boolean,\n redirectToPage: keyof HandlerUrls,\n}) {\n const redirectResultPromise = useMemo(\n () => getRedirectToPageResult(props.app, props.redirectToPage),\n [props.app, props.redirectToPage],\n );\n\n const redirectResult = use(redirectResultPromise);\n if (redirectResult.status === \"known-error\") {\n return <KnownErrorMessageCard error={redirectResult.error} fullPage={props.fullPage} />;\n }\n if (redirectResult.status === \"unknown-error\") {\n return <PredefinedMessageCard type=\"unknownError\" fullPage={props.fullPage} />;\n }\n return <MessageCard title=\"Redirecting...\" fullPage={props.fullPage} />;\n}\n\nexport function HexclaveHandlerClient(props: BaseHandlerProps & Partial<RouteProps> & { location?: string }) {\n // Use hooks to get app\n const hexclaveApp = useStackApp();\n const handlerUrls = hexclaveApp[hexclaveAppInternalsSymbol].getUrls();\n const clientOrigin = useClientOriginAfterHydration();\n\n const pathname = usePathname();\n const searchParamsFromHook = useSearchParams();\n const currentLocation = pathname;\n const searchParamsSource = searchParamsFromHook;\n\n const { path, searchParams, handlerPath } = useMemo(() => {\n const handlerPath = new URL(handlerUrls.handler, 'http://example.com').pathname;\n const relativePath = currentLocation.startsWith(handlerPath)\n ? currentLocation.slice(handlerPath.length).replace(/^\\/+/, '')\n : currentLocation.replace(/^\\/+/, '');\n\n return {\n path: relativePath,\n searchParams: Object.fromEntries(searchParamsSource.entries()),\n handlerPath,\n };\n }, [currentLocation, searchParamsSource, handlerUrls.handler]);\n\n const getDefaultUnknownPathUrl = (unknownPath: string): string | null => {\n return resolveUnknownHandlerPathFallbackUrl({\n defaultTarget: hexclaveApp[hexclaveAppInternalsSymbol].getConstructorOptions().urls?.default,\n projectId: hexclaveApp.projectId,\n unknownPath,\n });\n };\n\n const shouldRedirectToPage = (name: keyof HandlerUrls): boolean => {\n const url = handlerUrls[name];\n const isCrossDomainLocalOauthCallback = name === \"oauthCallback\" && searchParams.hexclave_cross_domain_auth === \"1\";\n if (isCrossDomainLocalOauthCallback) {\n return false;\n }\n return !isLocalHandlerUrlTarget({\n targetUrl: url,\n handlerPath,\n currentOrigin: clientOrigin,\n });\n };\n\n const result = renderComponent({\n path,\n searchParams,\n fullPage: props.fullPage,\n componentProps: props.componentProps,\n shouldRedirectToPage,\n getDefaultUnknownPathUrl,\n onNotFound: () =>\n notFound()\n ,\n app: hexclaveApp,\n });\n\n const redirectToPage = (result != null && typeof result === 'object' && 'redirectToPage' in result) ? result.redirectToPage : undefined;\n\n if (redirectToPage != null) {\n return (\n <Suspense fallback={<MessageCard title=\"Redirecting...\" fullPage={props.fullPage} />}>\n <RedirectToPage app={hexclaveApp} redirectToPage={redirectToPage} fullPage={props.fullPage} />\n </Suspense>\n );\n }\n\n if (result && 'redirect' in result) {\n redirect(result.redirect, RedirectType.replace);\n }\n\n\n return result;\n}\n\n// filter undefined values in object. if object itself is undefined, return undefined\nfunction filterUndefinedINU<T extends {}>(value: T | undefined): FilterUndefined<T> | undefined {\n return value === undefined ? value : filterUndefined(value);\n}\n\nfunction toAbsoluteOrRelativeRedirectTarget(url: URL): string {\n return url.origin === \"http://example.com\" ? getRelativePart(url) : url.toString();\n}\n\nfunction useClientOriginAfterHydration(): string | undefined {\n // The first hydrated render must match SSR. After hydration, React re-checks\n // the snapshot and lets us distinguish same-path cross-origin handler URLs.\n return useSyncExternalStore(\n () => () => {},\n () => window.location.origin,\n () => undefined,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,MAAM,iBAAiB;CACrB,QAAQ;CACR,QAAQ;CACR,mBAAmB;CACnB,eAAe;CACf,gBAAgB;CAChB,SAAS;CACT,eAAe;CACf,mBAAmB;CACnB,gBAAgB;CAChB,iBAAiB;CACjB,gBAAgB;CAChB,KAAK;CACL,OAAO;CACP,YAAY;CACb;AAID,MAAM,cAAc;CAElB,GAAG,OAAO,YAAY,OAAO,QAAQ,eAAe,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,OAAO,MAAM,CAAC,CAAC;CAC3F,UAAU,eAAe;CACzB,YAAY,eAAe;CAC5B;AASD,SAAS,gBAAgB,OAStB;CACD,MAAM,EAAE,MAAM,cAAc,UAAU,gBAAgB,sBAAsB,0BAA0B,YAAY,QAAQ;AAE1H,SAAQ,MAAR;EACE,KAAK,eAAe;AAClB,OAAI,uBAAuB,SAAS,CAAE,QAAO,EAAE,gBAAgB,UAAmB;AAClF,UAAO,oBAAC;IACI;IACV;IACA,GAAI,mBAAmB,gBAAgB,OAAO;KAC9C;EAEJ,KAAK,eAAe;AAClB,OAAI,uBAAuB,SAAS,CAAE,QAAO,EAAE,gBAAgB,UAAmB;AAClF,UAAO,oBAAC;IACI;IACV;IACA,GAAI,mBAAmB,gBAAgB,OAAO;KAC9C;EAEJ,KAAK,eAAe;AA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C;;CAGJ,MAAM,wBAAwB,SAAqC;EACjE,MAAM,MAAM,YAAY;AAExB,MADwC,SAAS,mBAAmB,aAAa,+BAA+B,IAE9G,QAAO;AAET,SAAO,CAAC,wBAAwB;GAC9B,WAAW;GACX;GACA,eAAe;GAChB,CAAC;;CAGJ,MAAM,SAAS,gBAAgB;EAC7B;EACA;EACA,UAAU,MAAM;EAChB,gBAAgB,MAAM;EACtB;EACA;EACA,kBACE,UAAU;EAEZ,KAAK;EACN,CAAC;CAEF,MAAM,iBAAkB,UAAU,QAAQ,OAAO,WAAW,YAAY,oBAAoB,SAAU,OAAO,iBAAiB;AAE9H,KAAI,kBAAkB,KACpB,QACE,oBAAC;EAAS,UAAU,oBAACD;GAAY,OAAM;GAAiB,UAAU,MAAM;IAAY;YAClF,oBAAC;GAAe,KAAK;GAA6B;GAAgB,UAAU,MAAM;IAAY;GACrF;AAIf,KAAI,UAAU,cAAc,OAC1B,UAAS,OAAO,UAAU,aAAa,QAAQ;AAIjD,QAAO;;AAIT,SAAS,mBAAiC,OAAsD;AAC9F,QAAO,UAAU,SAAY,QAAQ,gBAAgB,MAAM;;AAG7D,SAAS,mCAAmC,KAAkB;AAC5D,QAAO,IAAI,WAAW,uBAAuB,gBAAgB,IAAI,GAAG,IAAI,UAAU;;AAGpF,SAAS,gCAAoD;AAG3D,QAAO,iCACO,UACN,OAAO,SAAS,cAChB,OACP"}
@@ -1591,7 +1591,7 @@ function createSupportTab(app) {
1591
1591
  function createComponentsTab(app) {
1592
1592
  const container = h("div", { className: "sdt-pg-layout" });
1593
1593
  const apiBaseUrl = resolveApiBaseUrl(app);
1594
- const urls = app.urls;
1594
+ const urls = app[hexclaveAppInternalsSymbol].getUrls();
1595
1595
  const urlOptions = app[hexclaveAppInternalsSymbol].getConstructorOptions().urls ?? {};
1596
1596
  const PAGE_ENTRIES = [
1597
1597
  {