@hexclave/next 1.0.3 → 1.0.5
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.
- package/dist/components/api-key-dialogs.d.ts +1 -1
- package/dist/components/api-key-dialogs.js.map +1 -1
- package/dist/components/api-key-table.d.ts +1 -1
- package/dist/components/api-key-table.js.map +1 -1
- package/dist/components/credential-sign-in.js.map +1 -1
- package/dist/components/credential-sign-up.js.map +1 -1
- package/dist/components/elements/form-warning.js.map +1 -1
- package/dist/components/elements/maybe-full-page.js.map +1 -1
- package/dist/components/elements/separator-with-text.js.map +1 -1
- package/dist/components/elements/sidebar-layout.js.map +1 -1
- package/dist/components/elements/ssr-layout-effect.js.map +1 -1
- package/dist/components/elements/user-avatar.js.map +1 -1
- package/dist/components/link.js.map +1 -1
- package/dist/components/magic-link-sign-in.js +2 -2
- package/dist/components/magic-link-sign-in.js.map +1 -1
- package/dist/components/message-cards/known-error-message-card.js +2 -2
- package/dist/components/message-cards/known-error-message-card.js.map +1 -1
- package/dist/components/message-cards/message-card.js.map +1 -1
- package/dist/components/message-cards/predefined-message-card.js +9 -9
- package/dist/components/message-cards/predefined-message-card.js.map +1 -1
- package/dist/components/oauth-button-group.js +2 -2
- package/dist/components/oauth-button-group.js.map +1 -1
- package/dist/components/oauth-button.js +2 -2
- package/dist/components/oauth-button.js.map +1 -1
- package/dist/components/passkey-button.js +2 -2
- package/dist/components/passkey-button.js.map +1 -1
- package/dist/components/profile-image-editor.js.map +1 -1
- package/dist/components/selected-team-switcher.d.ts +1 -1
- package/dist/components/selected-team-switcher.js.map +1 -1
- package/dist/components/team-icon.d.ts +1 -1
- package/dist/components/team-icon.js.map +1 -1
- package/dist/components/team-switcher.d.ts +1 -1
- package/dist/components/team-switcher.js.map +1 -1
- package/dist/components/use-in-iframe.js.map +1 -1
- package/dist/components/user-button.js.map +1 -1
- package/dist/components-page/account-settings/active-sessions/active-sessions-page.js.map +1 -1
- package/dist/components-page/account-settings/api-keys/api-keys-page.js.map +1 -1
- package/dist/components-page/account-settings/editable-text.js.map +1 -1
- package/dist/components-page/account-settings/email-and-auth/email-and-auth-page.js.map +1 -1
- package/dist/components-page/account-settings/email-and-auth/emails-section.js.map +1 -1
- package/dist/components-page/account-settings/email-and-auth/mfa-section.js.map +1 -1
- package/dist/components-page/account-settings/email-and-auth/otp-section.js.map +1 -1
- package/dist/components-page/account-settings/email-and-auth/passkey-section.js.map +1 -1
- package/dist/components-page/account-settings/email-and-auth/password-section.js.map +1 -1
- package/dist/components-page/account-settings/notifications/notifications-page.js.map +1 -1
- package/dist/components-page/account-settings/page-layout.js.map +1 -1
- package/dist/components-page/account-settings/payments/payments-page.d.ts +1 -1
- package/dist/components-page/account-settings/payments/payments-page.js.map +1 -1
- package/dist/components-page/account-settings/payments/payments-panel.d.ts +1 -1
- package/dist/components-page/account-settings/payments/payments-panel.js +3 -3
- package/dist/components-page/account-settings/payments/payments-panel.js.map +1 -1
- package/dist/components-page/account-settings/profile-page/profile-page.js.map +1 -1
- package/dist/components-page/account-settings/section.js.map +1 -1
- package/dist/components-page/account-settings/settings/delete-account-section.js.map +1 -1
- package/dist/components-page/account-settings/settings/settings-page.js.map +1 -1
- package/dist/components-page/account-settings/settings/sign-out-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/leave-team-section.d.ts +1 -1
- package/dist/components-page/account-settings/teams/leave-team-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-api-keys-section.d.ts +1 -1
- package/dist/components-page/account-settings/teams/team-api-keys-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-creation-page.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-display-name-section.d.ts +1 -1
- package/dist/components-page/account-settings/teams/team-display-name-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-member-invitation-section.d.ts +1 -1
- package/dist/components-page/account-settings/teams/team-member-invitation-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-member-list-section.d.ts +1 -1
- package/dist/components-page/account-settings/teams/team-member-list-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-page.d.ts +1 -1
- package/dist/components-page/account-settings/teams/team-page.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-profile-image-section.d.ts +1 -1
- package/dist/components-page/account-settings/teams/team-profile-image-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-profile-user-section.d.ts +1 -1
- package/dist/components-page/account-settings/teams/team-profile-user-section.js.map +1 -1
- package/dist/components-page/account-settings.js.map +1 -1
- package/dist/components-page/auth-page.d.ts.map +1 -1
- package/dist/components-page/auth-page.js +55 -10
- package/dist/components-page/auth-page.js.map +1 -1
- package/dist/components-page/cli-auth-confirm.js +3 -3
- package/dist/components-page/cli-auth-confirm.js.map +1 -1
- package/dist/components-page/cli-auth-confirm.test.js +4 -4
- package/dist/components-page/cli-auth-confirm.test.js.map +1 -1
- package/dist/components-page/email-verification.js +4 -4
- package/dist/components-page/email-verification.js.map +1 -1
- package/dist/components-page/error-page.js +9 -9
- package/dist/components-page/error-page.js.map +1 -1
- package/dist/components-page/forgot-password.js +4 -4
- package/dist/components-page/forgot-password.js.map +1 -1
- package/dist/components-page/{stack-handler-client.d.ts → hexclave-handler-client.d.ts} +4 -4
- package/dist/components-page/hexclave-handler-client.d.ts.map +1 -0
- package/dist/components-page/{stack-handler-client.js → hexclave-handler-client.js} +19 -18
- package/dist/components-page/hexclave-handler-client.js.map +1 -0
- package/dist/components-page/{stack-handler.d.ts → hexclave-handler.d.ts} +5 -5
- package/dist/components-page/hexclave-handler.d.ts.map +1 -0
- package/dist/components-page/{stack-handler.js → hexclave-handler.js} +4 -4
- package/dist/components-page/hexclave-handler.js.map +1 -0
- package/dist/components-page/magic-link-callback.js +7 -7
- package/dist/components-page/magic-link-callback.js.map +1 -1
- package/dist/components-page/mfa.js +4 -4
- package/dist/components-page/mfa.js.map +1 -1
- package/dist/components-page/oauth-callback.js +3 -3
- package/dist/components-page/oauth-callback.js.map +1 -1
- package/dist/components-page/onboarding.js +3 -3
- package/dist/components-page/onboarding.js.map +1 -1
- package/dist/components-page/password-reset.js +8 -8
- package/dist/components-page/password-reset.js.map +1 -1
- package/dist/components-page/sign-in.js.map +1 -1
- package/dist/components-page/sign-out.d.ts +1 -0
- package/dist/components-page/sign-out.d.ts.map +1 -1
- package/dist/components-page/sign-out.js +11 -5
- package/dist/components-page/sign-out.js.map +1 -1
- package/dist/components-page/sign-up.js.map +1 -1
- package/dist/components-page/team-creation.js.map +1 -1
- package/dist/components-page/team-invitation.js +16 -16
- package/dist/components-page/team-invitation.js.map +1 -1
- package/dist/dev-tool/dev-tool-core.d.ts +1 -1
- package/dist/dev-tool/dev-tool-core.js +11 -11
- package/dist/dev-tool/dev-tool-core.js.map +1 -1
- package/dist/dev-tool/dev-tool-styles.d.ts +1 -1
- package/dist/dev-tool/dev-tool-styles.js +371 -371
- package/dist/dev-tool/dev-tool-styles.js.map +1 -1
- package/dist/dev-tool/dev-tool-trigger-position.js.map +1 -1
- package/dist/dev-tool/dev-tool-trigger-position.test.js.map +1 -1
- package/dist/dev-tool/index.d.ts +4 -4
- package/dist/dev-tool/index.js +4 -4
- package/dist/dev-tool/index.js.map +1 -1
- package/dist/esm/components/api-key-dialogs.d.ts +1 -1
- package/dist/esm/components/api-key-dialogs.js.map +1 -1
- package/dist/esm/components/api-key-table.d.ts +1 -1
- package/dist/esm/components/api-key-table.js.map +1 -1
- package/dist/esm/components/credential-sign-in.js.map +1 -1
- package/dist/esm/components/credential-sign-up.js.map +1 -1
- package/dist/esm/components/elements/form-warning.js.map +1 -1
- package/dist/esm/components/elements/maybe-full-page.js.map +1 -1
- package/dist/esm/components/elements/separator-with-text.js.map +1 -1
- package/dist/esm/components/elements/sidebar-layout.js.map +1 -1
- package/dist/esm/components/elements/ssr-layout-effect.js.map +1 -1
- package/dist/esm/components/elements/user-avatar.js.map +1 -1
- package/dist/esm/components/link.js.map +1 -1
- package/dist/esm/components/magic-link-sign-in.js +2 -2
- package/dist/esm/components/magic-link-sign-in.js.map +1 -1
- package/dist/esm/components/message-cards/known-error-message-card.js +2 -2
- package/dist/esm/components/message-cards/known-error-message-card.js.map +1 -1
- package/dist/esm/components/message-cards/message-card.js.map +1 -1
- package/dist/esm/components/message-cards/predefined-message-card.js +9 -9
- package/dist/esm/components/message-cards/predefined-message-card.js.map +1 -1
- package/dist/esm/components/oauth-button-group.js +2 -2
- package/dist/esm/components/oauth-button-group.js.map +1 -1
- package/dist/esm/components/oauth-button.js +2 -2
- package/dist/esm/components/oauth-button.js.map +1 -1
- package/dist/esm/components/passkey-button.js +2 -2
- package/dist/esm/components/passkey-button.js.map +1 -1
- package/dist/esm/components/profile-image-editor.js.map +1 -1
- package/dist/esm/components/selected-team-switcher.js.map +1 -1
- package/dist/esm/components/team-icon.js.map +1 -1
- package/dist/esm/components/team-switcher.js.map +1 -1
- package/dist/esm/components/use-in-iframe.js.map +1 -1
- package/dist/esm/components/user-button.js.map +1 -1
- package/dist/esm/components-page/account-settings/active-sessions/active-sessions-page.js.map +1 -1
- package/dist/esm/components-page/account-settings/api-keys/api-keys-page.js.map +1 -1
- package/dist/esm/components-page/account-settings/editable-text.js.map +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/email-and-auth-page.js.map +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/emails-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/mfa-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/otp-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/passkey-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/password-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/notifications/notifications-page.js.map +1 -1
- package/dist/esm/components-page/account-settings/page-layout.js.map +1 -1
- package/dist/esm/components-page/account-settings/payments/payments-page.js.map +1 -1
- package/dist/esm/components-page/account-settings/payments/payments-panel.d.ts +1 -1
- package/dist/esm/components-page/account-settings/payments/payments-panel.js +3 -3
- package/dist/esm/components-page/account-settings/payments/payments-panel.js.map +1 -1
- package/dist/esm/components-page/account-settings/profile-page/profile-page.js.map +1 -1
- package/dist/esm/components-page/account-settings/section.js.map +1 -1
- package/dist/esm/components-page/account-settings/settings/delete-account-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/settings/settings-page.js.map +1 -1
- package/dist/esm/components-page/account-settings/settings/sign-out-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/leave-team-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-api-keys-section.d.ts +1 -1
- package/dist/esm/components-page/account-settings/teams/team-api-keys-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-creation-page.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-display-name-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-member-invitation-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-member-list-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-page.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-profile-image-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-profile-user-section.js.map +1 -1
- package/dist/esm/components-page/account-settings.js.map +1 -1
- package/dist/esm/components-page/auth-page.d.ts.map +1 -1
- package/dist/esm/components-page/auth-page.js +56 -11
- package/dist/esm/components-page/auth-page.js.map +1 -1
- package/dist/esm/components-page/cli-auth-confirm.js +3 -3
- package/dist/esm/components-page/cli-auth-confirm.js.map +1 -1
- package/dist/esm/components-page/cli-auth-confirm.test.js +4 -4
- package/dist/esm/components-page/cli-auth-confirm.test.js.map +1 -1
- package/dist/esm/components-page/email-verification.js +4 -4
- package/dist/esm/components-page/email-verification.js.map +1 -1
- package/dist/esm/components-page/error-page.js +9 -9
- package/dist/esm/components-page/error-page.js.map +1 -1
- package/dist/esm/components-page/forgot-password.js +4 -4
- package/dist/esm/components-page/forgot-password.js.map +1 -1
- package/dist/esm/components-page/{stack-handler-client.d.ts → hexclave-handler-client.d.ts} +4 -4
- package/dist/esm/components-page/hexclave-handler-client.d.ts.map +1 -0
- package/dist/esm/components-page/{stack-handler-client.js → hexclave-handler-client.js} +17 -16
- package/dist/esm/components-page/hexclave-handler-client.js.map +1 -0
- package/dist/esm/components-page/{stack-handler.d.ts → hexclave-handler.d.ts} +5 -5
- package/dist/esm/components-page/hexclave-handler.d.ts.map +1 -0
- package/dist/esm/components-page/{stack-handler.js → hexclave-handler.js} +4 -4
- package/dist/esm/components-page/hexclave-handler.js.map +1 -0
- package/dist/esm/components-page/magic-link-callback.js +7 -7
- package/dist/esm/components-page/magic-link-callback.js.map +1 -1
- package/dist/esm/components-page/mfa.js +4 -4
- package/dist/esm/components-page/mfa.js.map +1 -1
- package/dist/esm/components-page/oauth-callback.js +3 -3
- package/dist/esm/components-page/oauth-callback.js.map +1 -1
- package/dist/esm/components-page/onboarding.js +3 -3
- package/dist/esm/components-page/onboarding.js.map +1 -1
- package/dist/esm/components-page/password-reset.js +8 -8
- package/dist/esm/components-page/password-reset.js.map +1 -1
- package/dist/esm/components-page/sign-in.js.map +1 -1
- package/dist/esm/components-page/sign-out.d.ts +1 -0
- package/dist/esm/components-page/sign-out.d.ts.map +1 -1
- package/dist/esm/components-page/sign-out.js +11 -5
- package/dist/esm/components-page/sign-out.js.map +1 -1
- package/dist/esm/components-page/sign-up.js.map +1 -1
- package/dist/esm/components-page/team-creation.js.map +1 -1
- package/dist/esm/components-page/team-invitation.js +16 -16
- package/dist/esm/components-page/team-invitation.js.map +1 -1
- package/dist/esm/dev-tool/dev-tool-core.d.ts +1 -1
- package/dist/esm/dev-tool/dev-tool-core.js +10 -10
- package/dist/esm/dev-tool/dev-tool-core.js.map +1 -1
- package/dist/esm/dev-tool/dev-tool-styles.d.ts +1 -1
- package/dist/esm/dev-tool/dev-tool-styles.js +371 -371
- package/dist/esm/dev-tool/dev-tool-styles.js.map +1 -1
- package/dist/esm/dev-tool/dev-tool-trigger-position.js.map +1 -1
- package/dist/esm/dev-tool/dev-tool-trigger-position.test.js.map +1 -1
- package/dist/esm/dev-tool/index.d.ts +4 -4
- package/dist/esm/dev-tool/index.js +4 -4
- package/dist/esm/dev-tool/index.js.map +1 -1
- package/dist/esm/generated/global-css.d.ts +1 -1
- package/dist/esm/generated/global-css.js +1 -1
- package/dist/esm/generated/global-css.js.map +1 -1
- package/dist/esm/generated/quetzal-translations.js.map +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +3 -3
- package/dist/esm/integrations/convex/component/convex.config.js.map +1 -1
- package/dist/esm/integrations/convex.js +1 -1
- package/dist/esm/integrations/convex.js.map +1 -1
- package/dist/esm/lib/auth.js.map +1 -1
- package/dist/esm/lib/auth.test.js.map +1 -1
- package/dist/esm/lib/cookie.js +2 -2
- package/dist/esm/lib/cookie.js.map +1 -1
- package/dist/esm/lib/env.js.map +1 -1
- package/dist/{lib/stack-app → esm/lib/hexclave-app}/api-keys/index.d.ts +2 -2
- package/dist/esm/lib/hexclave-app/api-keys/index.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/api-keys/index.js +1 -1
- package/dist/esm/lib/hexclave-app/api-keys/index.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/admin-app-impl.d.ts +6 -6
- package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/admin-app-impl.js +7 -7
- package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/client-app-impl.cross-domain.test.js +2 -2
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/client-app-impl.d.ts +13 -13
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/client-app-impl.js +23 -30
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/client-app-impl.oauth-prefetch.test.js +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.oauth-prefetch.test.js.map +1 -0
- package/dist/{lib/stack-app → esm/lib/hexclave-app}/apps/implementations/common.d.ts +4 -4
- package/dist/esm/lib/hexclave-app/apps/implementations/common.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/common.js +7 -7
- package/dist/esm/lib/hexclave-app/apps/implementations/common.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/event-tracker.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/event-tracker.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/event-tracker.js +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/event-tracker.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/event-tracker.test.js +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/event-tracker.test.js.map +1 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/index.d.ts +9 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/index.d.ts.map +1 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/index.js +27 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/index.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/redirect-page-urls.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/redirect-page-urls.js +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/server-app-impl.d.ts +4 -4
- package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/server-app-impl.js +6 -6
- package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.js.map +1 -0
- package/dist/{lib/stack-app → esm/lib/hexclave-app}/apps/implementations/session-refresh-subscription.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/session-refresh-subscription.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/session-refresh-subscription.js +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/session-refresh-subscription.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/session-refresh-subscription.test.js +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/session-refresh-subscription.test.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/session-replay.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/session-replay.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/session-replay.js +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/session-replay.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/session-replay.test.js +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/session-replay.test.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/interfaces/admin-app.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/apps/interfaces/admin-app.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/interfaces/admin-app.js +3 -3
- package/dist/esm/lib/hexclave-app/apps/interfaces/admin-app.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/interfaces/client-app.d.ts +4 -4
- package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/interfaces/client-app.js +3 -3
- package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/interfaces/server-app.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/apps/interfaces/server-app.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/apps/interfaces/server-app.js +3 -3
- package/dist/esm/lib/hexclave-app/apps/interfaces/server-app.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/common.d.ts +7 -7
- package/dist/esm/lib/hexclave-app/common.d.ts.map +1 -0
- package/dist/esm/lib/hexclave-app/common.js +7 -0
- package/dist/esm/lib/hexclave-app/common.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/connected-accounts/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/connected-accounts/index.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/contact-channels/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/contact-channels/index.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/contact-channels/index.js +1 -1
- package/dist/esm/lib/hexclave-app/contact-channels/index.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/customers/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/customers/index.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/data-vault/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/data-vault/index.d.ts.map +1 -0
- package/dist/{lib/stack-app → esm/lib/hexclave-app}/email/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/email/index.d.ts.map +1 -0
- package/dist/{lib/stack-app → esm/lib/hexclave-app}/email-templates/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/email-templates/index.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/email-templates/index.js +1 -1
- package/dist/esm/lib/hexclave-app/email-templates/index.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/index.d.ts +2 -2
- package/dist/esm/lib/{stack-app → hexclave-app}/index.js +2 -2
- package/dist/{lib/stack-app → esm/lib/hexclave-app}/internal-api-keys/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/internal-api-keys/index.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/internal-api-keys/index.js +1 -1
- package/dist/esm/lib/hexclave-app/internal-api-keys/index.js.map +1 -0
- package/dist/{lib/stack-app → esm/lib/hexclave-app}/notification-categories/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/notification-categories/index.d.ts.map +1 -0
- package/dist/{lib/stack-app → esm/lib/hexclave-app}/permissions/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/permissions/index.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/permissions/index.js +1 -1
- package/dist/esm/lib/hexclave-app/permissions/index.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/project-configs/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/project-configs/index.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/projects/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/projects/index.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/projects/index.js +1 -1
- package/dist/esm/lib/hexclave-app/projects/index.js.map +1 -0
- package/dist/{lib/stack-app → esm/lib/hexclave-app}/session-replays/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/session-replays/index.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/teams/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/teams/index.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/teams/index.js +1 -1
- package/dist/esm/lib/hexclave-app/teams/index.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/url-targets.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/url-targets.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/url-targets.js +2 -2
- package/dist/esm/lib/hexclave-app/url-targets.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/url-targets.test.js +1 -1
- package/dist/esm/lib/hexclave-app/url-targets.test.js.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/users/index.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/users/index.d.ts.map +1 -0
- package/dist/esm/lib/{stack-app → hexclave-app}/users/index.js +1 -1
- package/dist/esm/lib/hexclave-app/users/index.js.map +1 -0
- package/dist/esm/lib/hooks.d.ts +1 -1
- package/dist/esm/lib/hooks.js +9 -9
- package/dist/esm/lib/hooks.js.map +1 -1
- package/dist/esm/lib/translations.js.map +1 -1
- package/dist/esm/providers/hexclave-context.d.ts +11 -0
- package/dist/esm/providers/hexclave-context.d.ts.map +1 -0
- package/dist/esm/providers/hexclave-context.js +12 -0
- package/dist/esm/providers/hexclave-context.js.map +1 -0
- package/dist/esm/providers/{stack-provider-client.d.ts → hexclave-provider-client.d.ts} +5 -5
- package/dist/esm/providers/hexclave-provider-client.d.ts.map +1 -0
- package/dist/esm/providers/hexclave-provider-client.js +30 -0
- package/dist/esm/providers/hexclave-provider-client.js.map +1 -0
- package/dist/esm/providers/{stack-provider.d.ts → hexclave-provider.d.ts} +3 -3
- package/dist/esm/providers/hexclave-provider.d.ts.map +1 -0
- package/dist/esm/providers/{stack-provider.js → hexclave-provider.js} +6 -6
- package/dist/esm/providers/hexclave-provider.js.map +1 -0
- package/dist/esm/providers/theme-provider.js.map +1 -1
- package/dist/esm/providers/translation-provider-client.js.map +1 -1
- package/dist/esm/providers/translation-provider.js.map +1 -1
- package/dist/esm/tanstack-start-server-context.d.ts +1 -1
- package/dist/esm/utils/browser-script.js.map +1 -1
- package/dist/esm/utils/constants.js.map +1 -1
- package/dist/esm/utils/url.js.map +1 -1
- package/dist/generated/global-css.d.ts +1 -1
- package/dist/generated/global-css.js +1 -1
- package/dist/generated/global-css.js.map +1 -1
- package/dist/generated/quetzal-translations.js.map +1 -1
- package/dist/index.d.ts +18 -18
- package/dist/index.js +9 -9
- package/dist/integrations/convex/component/convex.config.d.ts +2 -2
- package/dist/integrations/convex/component/convex.config.d.ts.map +1 -1
- package/dist/integrations/convex/component/convex.config.js.map +1 -1
- package/dist/integrations/convex.js +2 -2
- package/dist/integrations/convex.js.map +1 -1
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/auth.test.js.map +1 -1
- package/dist/lib/cookie.js +2 -2
- package/dist/lib/cookie.js.map +1 -1
- package/dist/lib/env.js.map +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/api-keys/index.d.ts +2 -2
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/api-keys/index.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/api-keys/index.js +1 -1
- package/dist/lib/hexclave-app/api-keys/index.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/admin-app-impl.d.ts +6 -6
- package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/admin-app-impl.js +5 -5
- package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/client-app-impl.cross-domain.test.js +2 -2
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/client-app-impl.d.ts +13 -13
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.d.ts.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/client-app-impl.js +22 -29
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/client-app-impl.oauth-prefetch.test.js +1 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.oauth-prefetch.test.js.map +1 -0
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/apps/implementations/common.d.ts +4 -4
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/apps/implementations/common.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/common.js +6 -6
- package/dist/lib/hexclave-app/apps/implementations/common.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/event-tracker.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/apps/implementations/event-tracker.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/event-tracker.js +1 -1
- package/dist/lib/hexclave-app/apps/implementations/event-tracker.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/event-tracker.test.js +1 -1
- package/dist/lib/hexclave-app/apps/implementations/event-tracker.test.js.map +1 -0
- package/dist/lib/hexclave-app/apps/implementations/index.d.ts +9 -0
- package/dist/lib/hexclave-app/apps/implementations/index.d.ts.map +1 -0
- package/dist/lib/hexclave-app/apps/implementations/index.js +31 -0
- package/dist/lib/hexclave-app/apps/implementations/index.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/redirect-page-urls.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/apps/implementations/redirect-page-urls.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/redirect-page-urls.js +1 -1
- package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/server-app-impl.d.ts +4 -4
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/apps/implementations/server-app-impl.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/server-app-impl.js +5 -5
- package/dist/lib/hexclave-app/apps/implementations/server-app-impl.js.map +1 -0
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/apps/implementations/session-refresh-subscription.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/apps/implementations/session-refresh-subscription.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/session-refresh-subscription.js +1 -1
- package/dist/lib/hexclave-app/apps/implementations/session-refresh-subscription.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/session-refresh-subscription.test.js +1 -1
- package/dist/lib/hexclave-app/apps/implementations/session-refresh-subscription.test.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/session-replay.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/apps/implementations/session-replay.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/session-replay.js +1 -1
- package/dist/lib/hexclave-app/apps/implementations/session-replay.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/implementations/session-replay.test.js +1 -1
- package/dist/lib/hexclave-app/apps/implementations/session-replay.test.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/interfaces/admin-app.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/apps/interfaces/admin-app.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/apps/interfaces/admin-app.js +2 -2
- package/dist/lib/hexclave-app/apps/interfaces/admin-app.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/interfaces/client-app.d.ts +4 -4
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/apps/interfaces/client-app.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/apps/interfaces/client-app.js +2 -2
- package/dist/lib/hexclave-app/apps/interfaces/client-app.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/apps/interfaces/server-app.d.ts +2 -2
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/apps/interfaces/server-app.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/apps/interfaces/server-app.js +2 -2
- package/dist/lib/hexclave-app/apps/interfaces/server-app.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/common.d.ts +8 -8
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/common.d.ts.map +1 -1
- package/dist/lib/hexclave-app/common.js +9 -0
- package/dist/lib/hexclave-app/common.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/connected-accounts/index.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/connected-accounts/index.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/contact-channels/index.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/contact-channels/index.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/contact-channels/index.js +1 -1
- package/dist/lib/hexclave-app/contact-channels/index.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/customers/index.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/customers/index.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/data-vault/index.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/data-vault/index.d.ts.map +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/email/index.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/email/index.d.ts.map +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/email-templates/index.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/email-templates/index.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/email-templates/index.js +1 -1
- package/dist/lib/hexclave-app/email-templates/index.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/index.d.ts +2 -2
- package/dist/lib/{stack-app → hexclave-app}/index.js +2 -2
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/internal-api-keys/index.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/internal-api-keys/index.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/internal-api-keys/index.js +1 -1
- package/dist/lib/hexclave-app/internal-api-keys/index.js.map +1 -0
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/notification-categories/index.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/notification-categories/index.d.ts.map +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/permissions/index.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/permissions/index.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/permissions/index.js +1 -1
- package/dist/lib/hexclave-app/permissions/index.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/project-configs/index.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/project-configs/index.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/projects/index.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/projects/index.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/projects/index.js +1 -1
- package/dist/lib/hexclave-app/projects/index.js.map +1 -0
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/session-replays/index.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/session-replays/index.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/teams/index.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/teams/index.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/teams/index.js +1 -1
- package/dist/lib/hexclave-app/teams/index.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/url-targets.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/url-targets.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/url-targets.js +2 -2
- package/dist/lib/hexclave-app/url-targets.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/url-targets.test.js +1 -1
- package/dist/lib/hexclave-app/url-targets.test.js.map +1 -0
- package/dist/lib/{stack-app → hexclave-app}/users/index.d.ts +1 -1
- package/dist/{esm/lib/stack-app → lib/hexclave-app}/users/index.d.ts.map +1 -1
- package/dist/lib/{stack-app → hexclave-app}/users/index.js +1 -1
- package/dist/lib/hexclave-app/users/index.js.map +1 -0
- package/dist/lib/hooks.d.ts +3 -3
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/hooks.js +9 -9
- package/dist/lib/hooks.js.map +1 -1
- package/dist/lib/translations.js.map +1 -1
- package/dist/providers/hexclave-context.d.ts +11 -0
- package/dist/providers/hexclave-context.d.ts.map +1 -0
- package/dist/providers/hexclave-context.js +15 -0
- package/dist/providers/hexclave-context.js.map +1 -0
- package/dist/providers/{stack-provider-client.d.ts → hexclave-provider-client.d.ts} +5 -5
- package/dist/providers/hexclave-provider-client.d.ts.map +1 -0
- package/dist/providers/{stack-provider-client.js → hexclave-provider-client.js} +9 -9
- package/dist/providers/hexclave-provider-client.js.map +1 -0
- package/dist/providers/{stack-provider.d.ts → hexclave-provider.d.ts} +5 -5
- package/dist/providers/hexclave-provider.d.ts.map +1 -0
- package/dist/providers/{stack-provider.js → hexclave-provider.js} +6 -6
- package/dist/providers/hexclave-provider.js.map +1 -0
- package/dist/providers/theme-provider.js.map +1 -1
- package/dist/providers/translation-provider-client.js.map +1 -1
- package/dist/providers/translation-provider.js.map +1 -1
- package/dist/{storage-kTmOAWHW.d.ts → storage-CKzvsBxG.d.ts} +18 -18
- package/dist/{storage-kTmOAWHW.d.ts.map → storage-CKzvsBxG.d.ts.map} +1 -1
- package/dist/tanstack-start-server-context.d.ts +1 -1
- package/dist/utils/browser-script.js.map +1 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/url.js.map +1 -1
- package/package.json +6 -5
- package/src/components/api-key-dialogs.tsx +173 -0
- package/src/components/api-key-table.tsx +127 -0
- package/src/components/credential-sign-in.tsx +83 -0
- package/src/components/credential-sign-up.tsx +108 -0
- package/src/components/elements/form-warning.tsx +17 -0
- package/src/components/elements/maybe-full-page.tsx +60 -0
- package/src/components/elements/separator-with-text.tsx +22 -0
- package/src/components/elements/sidebar-layout.tsx +136 -0
- package/src/components/elements/ssr-layout-effect.tsx +24 -0
- package/src/components/elements/user-avatar.tsx +32 -0
- package/src/components/link.tsx +40 -0
- package/src/components/magic-link-sign-in.tsx +143 -0
- package/src/components/message-cards/known-error-message-card.tsx +33 -0
- package/src/components/message-cards/message-card.tsx +46 -0
- package/src/components/message-cards/predefined-message-card.tsx +88 -0
- package/src/components/oauth-button-group.tsx +35 -0
- package/src/components/oauth-button.tsx +222 -0
- package/src/components/passkey-button.tsx +43 -0
- package/src/components/profile-image-editor.tsx +194 -0
- package/src/components/selected-team-switcher.tsx +97 -0
- package/src/components/team-icon.tsx +30 -0
- package/src/components/team-switcher.tsx +191 -0
- package/src/components/use-in-iframe.tsx +18 -0
- package/src/components/user-button.tsx +157 -0
- package/src/components-page/account-settings/active-sessions/active-sessions-page.tsx +238 -0
- package/src/components-page/account-settings/api-keys/api-keys-page.tsx +157 -0
- package/src/components-page/account-settings/editable-text.tsx +53 -0
- package/src/components-page/account-settings/email-and-auth/email-and-auth-page.tsx +24 -0
- package/src/components-page/account-settings/email-and-auth/emails-section.tsx +201 -0
- package/src/components-page/account-settings/email-and-auth/mfa-section.tsx +139 -0
- package/src/components-page/account-settings/email-and-auth/otp-section.tsx +102 -0
- package/src/components-page/account-settings/email-and-auth/passkey-section.tsx +112 -0
- package/src/components-page/account-settings/email-and-auth/password-section.tsx +174 -0
- package/src/components-page/account-settings/notifications/notifications-page.tsx +44 -0
- package/src/components-page/account-settings/page-layout.tsx +11 -0
- package/src/components-page/account-settings/payments/payments-page.tsx +73 -0
- package/src/components-page/account-settings/payments/payments-panel.tsx +543 -0
- package/src/components-page/account-settings/profile-page/profile-page.tsx +61 -0
- package/src/components-page/account-settings/section.tsx +26 -0
- package/src/components-page/account-settings/settings/delete-account-section.tsx +85 -0
- package/src/components-page/account-settings/settings/settings-page.tsx +19 -0
- package/src/components-page/account-settings/settings/sign-out-section.tsx +40 -0
- package/src/components-page/account-settings/teams/leave-team-section.tsx +57 -0
- package/src/components-page/account-settings/teams/team-api-keys-section.tsx +74 -0
- package/src/components-page/account-settings/teams/team-creation-page.tsx +92 -0
- package/src/components-page/account-settings/teams/team-display-name-section.tsx +31 -0
- package/src/components-page/account-settings/teams/team-member-invitation-section.tsx +128 -0
- package/src/components-page/account-settings/teams/team-member-list-section.tsx +59 -0
- package/src/components-page/account-settings/teams/team-page.tsx +28 -0
- package/src/components-page/account-settings/teams/team-profile-image-section.tsx +33 -0
- package/src/components-page/account-settings/teams/team-profile-user-section.tsx +29 -0
- package/src/components-page/account-settings.tsx +343 -0
- package/src/components-page/auth-page.tsx +206 -0
- package/src/components-page/cli-auth-confirm.test.tsx +204 -0
- package/src/components-page/cli-auth-confirm.tsx +278 -0
- package/src/components-page/email-verification.tsx +76 -0
- package/src/components-page/error-page.tsx +105 -0
- package/src/components-page/forgot-password.tsx +105 -0
- package/src/components-page/hexclave-handler-client.tsx +325 -0
- package/src/components-page/hexclave-handler.tsx +48 -0
- package/src/components-page/magic-link-callback.tsx +92 -0
- package/src/components-page/mfa.tsx +222 -0
- package/src/components-page/oauth-callback.tsx +78 -0
- package/src/components-page/onboarding.tsx +176 -0
- package/src/components-page/password-reset.tsx +185 -0
- package/src/components-page/section.tsx +27 -0
- package/src/components-page/sign-in.tsx +34 -0
- package/src/components-page/sign-out.tsx +37 -0
- package/src/components-page/sign-up.tsx +24 -0
- package/src/components-page/team-creation.tsx +78 -0
- package/src/components-page/team-invitation.tsx +150 -0
- package/src/dev-tool/dev-tool-core.ts +2460 -0
- package/src/dev-tool/dev-tool-styles.ts +2758 -0
- package/src/dev-tool/dev-tool-trigger-position.test.ts +113 -0
- package/src/dev-tool/dev-tool-trigger-position.ts +109 -0
- package/src/dev-tool/index.ts +149 -0
- package/src/generated/.gitignore +3 -0
- package/src/generated/quetzal-translations.ts +4312 -0
- package/src/global.css +13 -0
- package/src/global.d.ts +5 -0
- package/src/index.ts +39 -0
- package/src/integrations/convex/component/README.md +74 -0
- package/src/integrations/convex/component/convex.config.ts +9 -0
- package/src/integrations/convex.ts +28 -0
- package/src/lib/auth.test.ts +67 -0
- package/src/lib/auth.ts +175 -0
- package/src/lib/cookie.ts +421 -0
- package/src/lib/env.ts +93 -0
- package/src/lib/hexclave-app/api-keys/index.ts +73 -0
- package/src/lib/hexclave-app/apps/implementations/admin-app-impl.ts +1261 -0
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.ts +141 -0
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.oauth-prefetch.test.ts +36 -0
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.ts +3912 -0
- package/src/lib/hexclave-app/apps/implementations/common.ts +244 -0
- package/src/lib/hexclave-app/apps/implementations/event-tracker.test.ts +105 -0
- package/src/lib/hexclave-app/apps/implementations/event-tracker.ts +306 -0
- package/src/lib/hexclave-app/apps/implementations/index.ts +35 -0
- package/src/lib/hexclave-app/apps/implementations/redirect-page-urls.ts +342 -0
- package/src/lib/hexclave-app/apps/implementations/server-app-impl.ts +1619 -0
- package/src/lib/hexclave-app/apps/implementations/session-refresh-subscription.test.ts +106 -0
- package/src/lib/hexclave-app/apps/implementations/session-refresh-subscription.ts +52 -0
- package/src/lib/hexclave-app/apps/implementations/session-replay.test.ts +33 -0
- package/src/lib/hexclave-app/apps/implementations/session-replay.ts +356 -0
- package/src/lib/hexclave-app/apps/index.ts +40 -0
- package/src/lib/hexclave-app/apps/interfaces/admin-app.ts +192 -0
- package/src/lib/hexclave-app/apps/interfaces/client-app.ts +180 -0
- package/src/lib/hexclave-app/apps/interfaces/server-app.ts +129 -0
- package/src/lib/hexclave-app/common.ts +216 -0
- package/src/lib/hexclave-app/connected-accounts/index.ts +49 -0
- package/src/lib/hexclave-app/contact-channels/index.ts +80 -0
- package/src/lib/hexclave-app/customers/index.ts +158 -0
- package/src/lib/hexclave-app/data-vault/index.ts +12 -0
- package/src/lib/hexclave-app/email/index.ts +280 -0
- package/src/lib/hexclave-app/email-templates/index.ts +24 -0
- package/src/lib/hexclave-app/index.ts +146 -0
- package/src/lib/hexclave-app/internal-api-keys/index.ts +55 -0
- package/src/lib/hexclave-app/notification-categories/index.ts +12 -0
- package/src/lib/hexclave-app/permissions/index.ts +75 -0
- package/src/lib/hexclave-app/project-configs/index.ts +103 -0
- package/src/lib/hexclave-app/projects/index.ts +236 -0
- package/src/lib/hexclave-app/session-replays/index.ts +72 -0
- package/src/lib/hexclave-app/teams/index.ts +206 -0
- package/src/lib/hexclave-app/url-targets.test.ts +253 -0
- package/src/lib/hexclave-app/url-targets.ts +395 -0
- package/src/lib/hexclave-app/users/index.ts +523 -0
- package/src/lib/hooks.tsx +63 -0
- package/src/lib/translations.tsx +23 -0
- package/src/providers/hexclave-context.tsx +20 -0
- package/src/providers/hexclave-provider-client.tsx +39 -0
- package/src/providers/hexclave-provider.tsx +48 -0
- package/src/providers/theme-provider.tsx +121 -0
- package/src/providers/translation-provider-client.tsx +35 -0
- package/src/providers/translation-provider.tsx +25 -0
- package/src/tanstack-start-server-context.d.ts +13 -0
- package/src/utils/browser-script.tsx +135 -0
- package/src/utils/constants.tsx +58 -0
- package/src/utils/url.ts +24 -0
- package/dist/components-page/stack-handler-client.d.ts.map +0 -1
- package/dist/components-page/stack-handler-client.js.map +0 -1
- package/dist/components-page/stack-handler.d.ts.map +0 -1
- package/dist/components-page/stack-handler.js.map +0 -1
- package/dist/esm/components-page/stack-handler-client.d.ts.map +0 -1
- package/dist/esm/components-page/stack-handler-client.js.map +0 -1
- package/dist/esm/components-page/stack-handler.d.ts.map +0 -1
- package/dist/esm/components-page/stack-handler.js.map +0 -1
- package/dist/esm/lib/stack-app/api-keys/index.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.d.ts.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.d.ts.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.oauth-prefetch.test.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/event-tracker.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/event-tracker.test.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/index.d.ts +0 -9
- package/dist/esm/lib/stack-app/apps/implementations/index.d.ts.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/index.js +0 -27
- package/dist/esm/lib/stack-app/apps/implementations/index.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/redirect-page-urls.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/session-refresh-subscription.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/session-refresh-subscription.test.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.test.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +0 -1
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js.map +0 -1
- package/dist/esm/lib/stack-app/common.js +0 -7
- package/dist/esm/lib/stack-app/common.js.map +0 -1
- package/dist/esm/lib/stack-app/contact-channels/index.js.map +0 -1
- package/dist/esm/lib/stack-app/email-templates/index.js.map +0 -1
- package/dist/esm/lib/stack-app/internal-api-keys/index.js.map +0 -1
- package/dist/esm/lib/stack-app/permissions/index.js.map +0 -1
- package/dist/esm/lib/stack-app/projects/index.js.map +0 -1
- package/dist/esm/lib/stack-app/teams/index.js.map +0 -1
- package/dist/esm/lib/stack-app/url-targets.js.map +0 -1
- package/dist/esm/lib/stack-app/url-targets.test.js.map +0 -1
- package/dist/esm/lib/stack-app/users/index.js.map +0 -1
- package/dist/esm/providers/stack-context.d.ts +0 -11
- package/dist/esm/providers/stack-context.d.ts.map +0 -1
- package/dist/esm/providers/stack-context.js +0 -12
- package/dist/esm/providers/stack-context.js.map +0 -1
- package/dist/esm/providers/stack-provider-client.d.ts.map +0 -1
- package/dist/esm/providers/stack-provider-client.js +0 -30
- package/dist/esm/providers/stack-provider-client.js.map +0 -1
- package/dist/esm/providers/stack-provider.d.ts.map +0 -1
- package/dist/esm/providers/stack-provider.js.map +0 -1
- package/dist/lib/stack-app/api-keys/index.d.ts.map +0 -1
- package/dist/lib/stack-app/api-keys/index.js.map +0 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.ts.map +0 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +0 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js.map +0 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts.map +0 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +0 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.oauth-prefetch.test.js.map +0 -1
- package/dist/lib/stack-app/apps/implementations/common.d.ts.map +0 -1
- package/dist/lib/stack-app/apps/implementations/common.js.map +0 -1
- package/dist/lib/stack-app/apps/implementations/event-tracker.d.ts.map +0 -1
- package/dist/lib/stack-app/apps/implementations/event-tracker.js.map +0 -1
- package/dist/lib/stack-app/apps/implementations/event-tracker.test.js.map +0 -1
- package/dist/lib/stack-app/apps/implementations/index.d.ts +0 -9
- package/dist/lib/stack-app/apps/implementations/index.d.ts.map +0 -1
- package/dist/lib/stack-app/apps/implementations/index.js +0 -31
- package/dist/lib/stack-app/apps/implementations/index.js.map +0 -1
- package/dist/lib/stack-app/apps/implementations/redirect-page-urls.d.ts.map +0 -1
- package/dist/lib/stack-app/apps/implementations/redirect-page-urls.js.map +0 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.d.ts.map +0 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +0 -1
- package/dist/lib/stack-app/apps/implementations/session-refresh-subscription.d.ts.map +0 -1
- package/dist/lib/stack-app/apps/implementations/session-refresh-subscription.js.map +0 -1
- package/dist/lib/stack-app/apps/implementations/session-refresh-subscription.test.js.map +0 -1
- package/dist/lib/stack-app/apps/implementations/session-replay.d.ts.map +0 -1
- package/dist/lib/stack-app/apps/implementations/session-replay.js.map +0 -1
- package/dist/lib/stack-app/apps/implementations/session-replay.test.js.map +0 -1
- package/dist/lib/stack-app/apps/interfaces/admin-app.d.ts.map +0 -1
- package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +0 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.d.ts.map +0 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.js.map +0 -1
- package/dist/lib/stack-app/apps/interfaces/server-app.d.ts.map +0 -1
- package/dist/lib/stack-app/apps/interfaces/server-app.js.map +0 -1
- package/dist/lib/stack-app/common.d.ts.map +0 -1
- package/dist/lib/stack-app/common.js +0 -9
- package/dist/lib/stack-app/common.js.map +0 -1
- package/dist/lib/stack-app/connected-accounts/index.d.ts.map +0 -1
- package/dist/lib/stack-app/contact-channels/index.d.ts.map +0 -1
- package/dist/lib/stack-app/contact-channels/index.js.map +0 -1
- package/dist/lib/stack-app/customers/index.d.ts.map +0 -1
- package/dist/lib/stack-app/data-vault/index.d.ts.map +0 -1
- package/dist/lib/stack-app/email/index.d.ts.map +0 -1
- package/dist/lib/stack-app/email-templates/index.d.ts.map +0 -1
- package/dist/lib/stack-app/email-templates/index.js.map +0 -1
- package/dist/lib/stack-app/internal-api-keys/index.d.ts.map +0 -1
- package/dist/lib/stack-app/internal-api-keys/index.js.map +0 -1
- package/dist/lib/stack-app/notification-categories/index.d.ts.map +0 -1
- package/dist/lib/stack-app/permissions/index.d.ts.map +0 -1
- package/dist/lib/stack-app/permissions/index.js.map +0 -1
- package/dist/lib/stack-app/project-configs/index.d.ts.map +0 -1
- package/dist/lib/stack-app/projects/index.d.ts.map +0 -1
- package/dist/lib/stack-app/projects/index.js.map +0 -1
- package/dist/lib/stack-app/session-replays/index.d.ts.map +0 -1
- package/dist/lib/stack-app/teams/index.d.ts.map +0 -1
- package/dist/lib/stack-app/teams/index.js.map +0 -1
- package/dist/lib/stack-app/url-targets.d.ts.map +0 -1
- package/dist/lib/stack-app/url-targets.js.map +0 -1
- package/dist/lib/stack-app/url-targets.test.js.map +0 -1
- package/dist/lib/stack-app/users/index.d.ts.map +0 -1
- package/dist/lib/stack-app/users/index.js.map +0 -1
- package/dist/providers/stack-context.d.ts +0 -11
- package/dist/providers/stack-context.d.ts.map +0 -1
- package/dist/providers/stack-context.js +0 -15
- package/dist/providers/stack-context.js.map +0 -1
- package/dist/providers/stack-provider-client.d.ts.map +0 -1
- package/dist/providers/stack-provider-client.js.map +0 -1
- package/dist/providers/stack-provider.d.ts.map +0 -1
- package/dist/providers/stack-provider.js.map +0 -1
- /package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/client-app-impl.cross-domain.test.d.ts +0 -0
- /package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/client-app-impl.oauth-prefetch.test.d.ts +0 -0
- /package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/event-tracker.test.d.ts +0 -0
- /package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/session-refresh-subscription.test.d.ts +0 -0
- /package/dist/esm/lib/{stack-app → hexclave-app}/apps/implementations/session-replay.test.d.ts +0 -0
- /package/dist/esm/lib/{stack-app → hexclave-app}/apps/index.d.ts +0 -0
- /package/dist/esm/lib/{stack-app → hexclave-app}/apps/index.js +0 -0
- /package/dist/esm/lib/{stack-app → hexclave-app}/connected-accounts/index.js +0 -0
- /package/dist/esm/lib/{stack-app → hexclave-app}/customers/index.js +0 -0
- /package/dist/esm/lib/{stack-app → hexclave-app}/data-vault/index.js +0 -0
- /package/dist/esm/lib/{stack-app → hexclave-app}/email/index.js +0 -0
- /package/dist/esm/lib/{stack-app → hexclave-app}/notification-categories/index.js +0 -0
- /package/dist/esm/lib/{stack-app → hexclave-app}/project-configs/index.js +0 -0
- /package/dist/esm/lib/{stack-app → hexclave-app}/session-replays/index.js +0 -0
- /package/dist/esm/lib/{stack-app → hexclave-app}/url-targets.test.d.ts +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/apps/implementations/client-app-impl.cross-domain.test.d.ts +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/apps/implementations/client-app-impl.oauth-prefetch.test.d.ts +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/apps/implementations/event-tracker.test.d.ts +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/apps/implementations/session-refresh-subscription.test.d.ts +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/apps/implementations/session-replay.test.d.ts +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/apps/index.d.ts +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/apps/index.js +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/connected-accounts/index.js +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/customers/index.js +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/data-vault/index.js +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/email/index.js +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/notification-categories/index.js +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/project-configs/index.js +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/session-replays/index.js +0 -0
- /package/dist/lib/{stack-app → hexclave-app}/url-targets.test.d.ts +0 -0
|
@@ -0,0 +1,2460 @@
|
|
|
1
|
+
|
|
2
|
+
//===========================================
|
|
3
|
+
// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template
|
|
4
|
+
//===========================================
|
|
5
|
+
|
|
6
|
+
import type { RequestLogEntry } from "@hexclave/shared/dist/interface/client-interface";
|
|
7
|
+
import { runAsynchronously } from "@hexclave/shared/dist/utils/promises";
|
|
8
|
+
import { isLocalhost } from "@hexclave/shared/dist/utils/urls";
|
|
9
|
+
import type { StackClientApp } from "../lib/hexclave-app";
|
|
10
|
+
import { envVars } from "../lib/env";
|
|
11
|
+
import { getBaseUrl } from "../lib/hexclave-app/apps/implementations/common";
|
|
12
|
+
import type { HandlerUrlOptions, HandlerUrls, HandlerUrlTarget } from "../lib/hexclave-app/common";
|
|
13
|
+
import { hexclaveAppInternalsSymbol } from "../lib/hexclave-app/common";
|
|
14
|
+
import { getPagePrompt } from "../lib/hexclave-app/url-targets";
|
|
15
|
+
import { devToolCSS } from "./dev-tool-styles";
|
|
16
|
+
import type { TriggerCorner, TriggerPlacement } from "./dev-tool-trigger-position";
|
|
17
|
+
import { clampTriggerPosition, getSnappedTriggerPlacement, resolveTriggerPosition } from "./dev-tool-trigger-position";
|
|
18
|
+
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// Types
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
|
|
23
|
+
type TabId = 'overview' | 'customize' | 'ai' | 'dashboard' | 'console' | 'support';
|
|
24
|
+
|
|
25
|
+
type TabResult = { element: HTMLElement, cleanup?: () => void };
|
|
26
|
+
|
|
27
|
+
type ApiLogEntry = {
|
|
28
|
+
id: string;
|
|
29
|
+
timestamp: number;
|
|
30
|
+
method: string;
|
|
31
|
+
url: string;
|
|
32
|
+
status?: number;
|
|
33
|
+
duration?: number;
|
|
34
|
+
error?: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type EventLogEntry = {
|
|
38
|
+
id: string;
|
|
39
|
+
timestamp: number;
|
|
40
|
+
type: 'error' | 'info';
|
|
41
|
+
message: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
type DevToolState = {
|
|
45
|
+
isOpen: boolean;
|
|
46
|
+
activeTab: TabId;
|
|
47
|
+
panelWidth: number;
|
|
48
|
+
panelHeight: number;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Constants
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
// Hexclave rebrand: UI-only local prefs — straight rename (one-time reset is harmless)
|
|
56
|
+
const STORAGE_KEY = '__hexclave-dev-tool-state';
|
|
57
|
+
const TRIGGER_POS_KEY = 'hexclave-devtool-trigger-position';
|
|
58
|
+
const ROOT_ID = '__hexclave-dev-tool-root';
|
|
59
|
+
const GLOBAL_INSTANCE_KEY = '__hexclave-dev-tool-instance';
|
|
60
|
+
const MAX_LOG_ENTRIES = 500;
|
|
61
|
+
const CONSOLE_LOG_BATCH_SIZE = 100;
|
|
62
|
+
const DRAG_THRESHOLD = 5;
|
|
63
|
+
const DOCS_URL = 'https://docs.hexclave.com';
|
|
64
|
+
|
|
65
|
+
const TABS: { id: TabId; label: string; icon: string }[] = [
|
|
66
|
+
{ id: 'overview', label: 'Overview', icon: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg>' },
|
|
67
|
+
{ id: 'customize', label: 'Customize', icon: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>' },
|
|
68
|
+
{ id: 'ai', label: 'AI', icon: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>' },
|
|
69
|
+
{ id: 'console', label: 'Console', icon: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/></svg>' },
|
|
70
|
+
{ id: 'dashboard', label: 'Dashboard', icon: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18"/><path d="M9 21V9"/></svg>' },
|
|
71
|
+
{ id: 'support', label: 'Support', icon: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>' },
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
const DEFAULT_STATE: DevToolState = {
|
|
75
|
+
isOpen: false,
|
|
76
|
+
activeTab: 'overview',
|
|
77
|
+
panelWidth: 800,
|
|
78
|
+
panelHeight: 520,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Hexclave mark — hexagon outline with three radial bars, monochrome via currentColor
|
|
82
|
+
// so it inherits the trigger logo's color. Sourced from apps/dashboard/public/hexclave-icon.svg
|
|
83
|
+
// (gradient + glow stripped; this is a tiny trigger glyph, not the full brand mark).
|
|
84
|
+
const HEXCLAVE_LOGO_SVG = '<svg width="16" height="16" viewBox="0 0 48 48" fill="none" stroke="currentColor" stroke-width="3" stroke-linejoin="miter"><path d="M 24 4 L 41.32 14 L 41.32 34 L 24 44 L 6.68 34 L 6.68 14 Z"/><path d="M 11 16.87 L 14 15.13 L 14 32.87 L 11 31.13 Z" fill="currentColor" stroke="none"/><path d="M 11 16.87 L 14 15.13 L 14 32.87 L 11 31.13 Z" fill="currentColor" stroke="none" transform="rotate(120 24 24)"/><path d="M 11 16.87 L 14 15.13 L 14 32.87 L 11 31.13 Z" fill="currentColor" stroke="none" transform="rotate(240 24 24)"/></svg>';
|
|
85
|
+
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
// State management
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
|
|
90
|
+
function loadState(): DevToolState {
|
|
91
|
+
try {
|
|
92
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
93
|
+
if (stored) {
|
|
94
|
+
const parsed = JSON.parse(stored);
|
|
95
|
+
// Migrate old 'components' tab name to 'customize'
|
|
96
|
+
if (parsed.activeTab === 'components') parsed.activeTab = 'customize';
|
|
97
|
+
if (parsed.activeTab === 'docs') parsed.activeTab = 'overview';
|
|
98
|
+
return { ...DEFAULT_STATE, ...parsed, isOpen: false };
|
|
99
|
+
}
|
|
100
|
+
} catch {}
|
|
101
|
+
return { ...DEFAULT_STATE };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function saveState(state: DevToolState) {
|
|
105
|
+
try {
|
|
106
|
+
// Keep layout preferences across pages, but do not reopen the panel automatically on remount.
|
|
107
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify({ ...state, isOpen: false }));
|
|
108
|
+
} catch {}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function createStateStore() {
|
|
112
|
+
let state = loadState();
|
|
113
|
+
const listeners = new Set<() => void>();
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
get: () => state,
|
|
117
|
+
update(partial: Partial<DevToolState>) {
|
|
118
|
+
state = { ...state, ...partial };
|
|
119
|
+
saveState(state);
|
|
120
|
+
listeners.forEach((fn) => fn());
|
|
121
|
+
},
|
|
122
|
+
subscribe(fn: () => void) {
|
|
123
|
+
listeners.add(fn);
|
|
124
|
+
return () => {
|
|
125
|
+
listeners.delete(fn);
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// ---------------------------------------------------------------------------
|
|
132
|
+
// Global log store (survives remounts, shared across instances)
|
|
133
|
+
// ---------------------------------------------------------------------------
|
|
134
|
+
|
|
135
|
+
type LogStore = {
|
|
136
|
+
apiLogs: ApiLogEntry[];
|
|
137
|
+
eventLogs: EventLogEntry[];
|
|
138
|
+
listeners: Set<() => void>;
|
|
139
|
+
addApiLog(entry: ApiLogEntry): void;
|
|
140
|
+
addEventLog(entry: EventLogEntry): void;
|
|
141
|
+
clear(): void;
|
|
142
|
+
subscribe(fn: () => void): () => void;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
type DevToolGlobalInstance = {
|
|
146
|
+
cleanup: () => void;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
function isDevToolGlobalInstance(value: unknown): value is DevToolGlobalInstance {
|
|
150
|
+
return typeof value === 'object' && value !== null && typeof Reflect.get(value, 'cleanup') === 'function';
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function getGlobalDevToolInstance(): DevToolGlobalInstance | null {
|
|
154
|
+
if (typeof window === 'undefined') return null;
|
|
155
|
+
const value: unknown = Reflect.get(window, GLOBAL_INSTANCE_KEY);
|
|
156
|
+
return isDevToolGlobalInstance(value) ? value : null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function setGlobalDevToolInstance(instance: DevToolGlobalInstance | null) {
|
|
160
|
+
if (typeof window === 'undefined') return;
|
|
161
|
+
if (instance === null) {
|
|
162
|
+
Reflect.deleteProperty(window, GLOBAL_INSTANCE_KEY);
|
|
163
|
+
} else {
|
|
164
|
+
Reflect.set(window, GLOBAL_INSTANCE_KEY, instance);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function getGlobalLogStore(): LogStore {
|
|
169
|
+
const g = globalThis as any;
|
|
170
|
+
if (!g.__STACK_DEV_TOOL_LOG_STORE__) {
|
|
171
|
+
g.__STACK_DEV_TOOL_LOG_STORE__ = {
|
|
172
|
+
apiLogs: [] as ApiLogEntry[],
|
|
173
|
+
eventLogs: [] as EventLogEntry[],
|
|
174
|
+
listeners: new Set<() => void>(),
|
|
175
|
+
addApiLog(entry: ApiLogEntry) {
|
|
176
|
+
this.apiLogs = [entry, ...this.apiLogs].slice(0, MAX_LOG_ENTRIES);
|
|
177
|
+
this.listeners.forEach((fn: () => void) => fn());
|
|
178
|
+
},
|
|
179
|
+
addEventLog(entry: EventLogEntry) {
|
|
180
|
+
this.eventLogs = [entry, ...this.eventLogs].slice(0, MAX_LOG_ENTRIES);
|
|
181
|
+
this.listeners.forEach((fn: () => void) => fn());
|
|
182
|
+
},
|
|
183
|
+
clear() {
|
|
184
|
+
this.apiLogs = [];
|
|
185
|
+
this.eventLogs = [];
|
|
186
|
+
this.listeners.forEach((fn: () => void) => fn());
|
|
187
|
+
},
|
|
188
|
+
subscribe(fn: () => void) {
|
|
189
|
+
this.listeners.add(fn);
|
|
190
|
+
return () => {
|
|
191
|
+
this.listeners.delete(fn);
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
return g.__STACK_DEV_TOOL_LOG_STORE__;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// ---------------------------------------------------------------------------
|
|
200
|
+
// Utility helpers
|
|
201
|
+
// ---------------------------------------------------------------------------
|
|
202
|
+
|
|
203
|
+
let _idCounter = 0;
|
|
204
|
+
function nextId() {
|
|
205
|
+
return `sdt-${++_idCounter}-${Date.now()}`;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function resolveApiBaseUrl(app: StackClientApp<true>): string {
|
|
209
|
+
const opts = app[hexclaveAppInternalsSymbol].getConstructorOptions();
|
|
210
|
+
return getBaseUrl(opts.baseUrl);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function shouldShowDashboardTab(app: StackClientApp<true>): boolean {
|
|
214
|
+
return envVars.NEXT_PUBLIC_STACK_IS_LOCAL_EMULATOR === "true" && isLocalhost(resolveApiBaseUrl(app));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function getTabsForApp(app: StackClientApp<true>): { id: TabId; label: string; icon: string }[] {
|
|
218
|
+
if (shouldShowDashboardTab(app)) {
|
|
219
|
+
return TABS;
|
|
220
|
+
}
|
|
221
|
+
return TABS.filter((tab) => tab.id !== 'dashboard');
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function deriveDashboardBaseUrl(apiBaseUrl: string): string {
|
|
225
|
+
try {
|
|
226
|
+
const url = new URL(apiBaseUrl);
|
|
227
|
+
if (url.hostname === 'localhost' || url.hostname === '127.0.0.1' || url.hostname === '[::1]') {
|
|
228
|
+
const port = url.port;
|
|
229
|
+
if (port && port.endsWith('02')) {
|
|
230
|
+
url.port = port.slice(0, -2) + '01';
|
|
231
|
+
}
|
|
232
|
+
return url.origin;
|
|
233
|
+
}
|
|
234
|
+
if (url.hostname.startsWith('api.')) {
|
|
235
|
+
url.hostname = 'app.' + url.hostname.slice(4);
|
|
236
|
+
return url.origin;
|
|
237
|
+
}
|
|
238
|
+
return url.origin;
|
|
239
|
+
} catch {
|
|
240
|
+
return 'https://app.hexclave.com';
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function resolveDashboardUrl(app: StackClientApp<true>): string {
|
|
245
|
+
const base = deriveDashboardBaseUrl(resolveApiBaseUrl(app));
|
|
246
|
+
return `${base}/projects/${encodeURIComponent(app.projectId)}`;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function formatTimestamp(ts: number): string {
|
|
250
|
+
return new Date(ts).toLocaleTimeString([], {
|
|
251
|
+
hour: '2-digit',
|
|
252
|
+
minute: '2-digit',
|
|
253
|
+
second: '2-digit',
|
|
254
|
+
fractionalSecondDigits: 3,
|
|
255
|
+
} as any);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function escapeHtml(str: string): string {
|
|
259
|
+
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function generateRandomEmail(): string {
|
|
263
|
+
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
264
|
+
let id = '';
|
|
265
|
+
for (let i = 0; i < 8; i++) {
|
|
266
|
+
id += chars[Math.floor(Math.random() * chars.length)];
|
|
267
|
+
}
|
|
268
|
+
return `dev-${id}@test.hexclave.com`;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
// DOM helpers
|
|
273
|
+
// ---------------------------------------------------------------------------
|
|
274
|
+
|
|
275
|
+
function h<K extends keyof HTMLElementTagNameMap>(
|
|
276
|
+
tag: K,
|
|
277
|
+
attrs?: Record<string, any> | null,
|
|
278
|
+
...children: (string | Node | null | undefined)[]
|
|
279
|
+
): HTMLElementTagNameMap[K] {
|
|
280
|
+
const el = document.createElement(tag);
|
|
281
|
+
if (attrs) {
|
|
282
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
283
|
+
if (v == null) continue;
|
|
284
|
+
if (k === 'className') {
|
|
285
|
+
el.className = v;
|
|
286
|
+
} else if (k === 'style' && typeof v === 'object') {
|
|
287
|
+
Object.assign(el.style, v);
|
|
288
|
+
} else if (k.startsWith('on') && typeof v === 'function') {
|
|
289
|
+
el.addEventListener(k.slice(2).toLowerCase(), v);
|
|
290
|
+
} else {
|
|
291
|
+
el.setAttribute(k, String(v));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
for (const child of children) {
|
|
296
|
+
if (child == null) continue;
|
|
297
|
+
el.appendChild(typeof child === 'string' ? document.createTextNode(child) : child);
|
|
298
|
+
}
|
|
299
|
+
return el;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function setHtml(el: HTMLElement, html: string) {
|
|
303
|
+
el.innerHTML = html;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function hasAppendChild(value: unknown): value is { appendChild(node: Node): void } {
|
|
307
|
+
return typeof value === 'object' && value !== null && typeof Reflect.get(value, 'appendChild') === 'function';
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function parseMarkdownImage(line: string): { alt: string, src: string } | null {
|
|
311
|
+
const match = line.trim().match(/^!\[([^\]]*)\]\((.+)\)$/);
|
|
312
|
+
if (!match) return null;
|
|
313
|
+
|
|
314
|
+
const [, alt, src] = match;
|
|
315
|
+
const normalizedSrc = src.trim();
|
|
316
|
+
if (normalizedSrc === '') return null;
|
|
317
|
+
|
|
318
|
+
return {
|
|
319
|
+
alt: alt.trim(),
|
|
320
|
+
src: normalizedSrc,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function appendInlineMarkdown(container: HTMLElement, text: string) {
|
|
325
|
+
const tokenPattern = /(\[[^\]]+\]\([^)]+\)|`[^`\n]+`|\*\*[^*\n]+\*\*|__[^_\n]+__|\*[^*\n]+\*|_[^_\n]+_)/g;
|
|
326
|
+
let lastIndex = 0;
|
|
327
|
+
let match: RegExpExecArray | null;
|
|
328
|
+
|
|
329
|
+
while ((match = tokenPattern.exec(text)) !== null) {
|
|
330
|
+
if (match.index > lastIndex) {
|
|
331
|
+
container.appendChild(document.createTextNode(text.slice(lastIndex, match.index)));
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const token = match[0];
|
|
335
|
+
if (token.startsWith("`")) {
|
|
336
|
+
container.appendChild(h("code", { className: "sdt-ai-inline-code" }, token.slice(1, -1)));
|
|
337
|
+
} else if (token.startsWith("**") || token.startsWith("__")) {
|
|
338
|
+
const bold = h("strong", { className: "sdt-ai-bold" });
|
|
339
|
+
appendInlineMarkdown(bold, token.slice(2, -2));
|
|
340
|
+
container.appendChild(bold);
|
|
341
|
+
} else if (token.startsWith("*") || token.startsWith("_")) {
|
|
342
|
+
const italic = h("em");
|
|
343
|
+
appendInlineMarkdown(italic, token.slice(1, -1));
|
|
344
|
+
container.appendChild(italic);
|
|
345
|
+
} else {
|
|
346
|
+
const linkMatch = token.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
|
|
347
|
+
if (linkMatch) {
|
|
348
|
+
const [, linkText, href] = linkMatch;
|
|
349
|
+
const trimmedHref = href.trim();
|
|
350
|
+
if (/^(https?:\/\/|mailto:)/i.test(trimmedHref)) {
|
|
351
|
+
const link = h("a", {
|
|
352
|
+
className: "sdt-ai-link",
|
|
353
|
+
href: trimmedHref,
|
|
354
|
+
target: "_blank",
|
|
355
|
+
rel: "noopener noreferrer",
|
|
356
|
+
});
|
|
357
|
+
appendInlineMarkdown(link, linkText);
|
|
358
|
+
container.appendChild(link);
|
|
359
|
+
} else {
|
|
360
|
+
container.appendChild(document.createTextNode(token));
|
|
361
|
+
}
|
|
362
|
+
} else {
|
|
363
|
+
container.appendChild(document.createTextNode(token));
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
lastIndex = tokenPattern.lastIndex;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (lastIndex < text.length) {
|
|
371
|
+
container.appendChild(document.createTextNode(text.slice(lastIndex)));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// ---------------------------------------------------------------------------
|
|
376
|
+
// Trigger button (draggable pill — corner-snapping, icon only)
|
|
377
|
+
// ---------------------------------------------------------------------------
|
|
378
|
+
|
|
379
|
+
function createTrigger(onClick: () => void): { element: HTMLElement; cleanup: () => void } {
|
|
380
|
+
type Position = { left: number; top: number };
|
|
381
|
+
type Placement = TriggerPlacement;
|
|
382
|
+
|
|
383
|
+
// Measured lazily after the element is appended to the DOM.
|
|
384
|
+
let triggerSize = { width: 36, height: 36 };
|
|
385
|
+
|
|
386
|
+
function isPosition(value: unknown): value is Position {
|
|
387
|
+
if (typeof value !== 'object' || value === null) return false;
|
|
388
|
+
return typeof Reflect.get(value, 'left') === 'number' && typeof Reflect.get(value, 'top') === 'number';
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function isPlacement(value: unknown): value is Placement {
|
|
392
|
+
if (typeof value !== 'object' || value === null) return false;
|
|
393
|
+
const corner = Reflect.get(value, 'corner');
|
|
394
|
+
return ['top-left', 'top-right', 'bottom-left', 'bottom-right'].includes(String(corner));
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function loadPlacement(): Placement | null {
|
|
398
|
+
try {
|
|
399
|
+
const raw = localStorage.getItem(TRIGGER_POS_KEY);
|
|
400
|
+
if (!raw) return null;
|
|
401
|
+
const parsed = JSON.parse(raw);
|
|
402
|
+
|
|
403
|
+
if (isPlacement(parsed)) return parsed;
|
|
404
|
+
|
|
405
|
+
// Migrate old side-based placement { side, offset } to nearest corner.
|
|
406
|
+
if (typeof parsed === 'object' && parsed !== null && 'side' in parsed && 'offset' in parsed) {
|
|
407
|
+
const side = String(Reflect.get(parsed, 'side'));
|
|
408
|
+
const offset = Number(Reflect.get(parsed, 'offset'));
|
|
409
|
+
const vw = window.innerWidth;
|
|
410
|
+
const vh = window.innerHeight;
|
|
411
|
+
let corner: TriggerCorner;
|
|
412
|
+
if (side === 'right') corner = offset < vh / 2 ? 'top-right' : 'bottom-right';
|
|
413
|
+
else if (side === 'left') corner = offset < vh / 2 ? 'top-left' : 'bottom-left';
|
|
414
|
+
else if (side === 'top') corner = offset < vw / 2 ? 'top-left' : 'top-right';
|
|
415
|
+
else corner = offset < vw / 2 ? 'bottom-left' : 'bottom-right';
|
|
416
|
+
return { corner };
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// Migrate old absolute position.
|
|
420
|
+
if (isPosition(parsed)) {
|
|
421
|
+
return getSnappedTriggerPlacement(parsed, triggerSize, { width: window.innerWidth, height: window.innerHeight });
|
|
422
|
+
}
|
|
423
|
+
} catch {}
|
|
424
|
+
return null;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
function savePlacement(placement: Placement) {
|
|
428
|
+
try {
|
|
429
|
+
localStorage.setItem(TRIGGER_POS_KEY, JSON.stringify(placement));
|
|
430
|
+
} catch {}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
let animationTimeout: number | null = null;
|
|
434
|
+
|
|
435
|
+
function setPositionAnimation(isAnimated: boolean) {
|
|
436
|
+
if (animationTimeout !== null) {
|
|
437
|
+
window.clearTimeout(animationTimeout);
|
|
438
|
+
animationTimeout = null;
|
|
439
|
+
}
|
|
440
|
+
btn.classList.toggle('sdt-trigger-position-animated', isAnimated);
|
|
441
|
+
if (isAnimated) {
|
|
442
|
+
animationTimeout = window.setTimeout(() => {
|
|
443
|
+
animationTimeout = null;
|
|
444
|
+
btn.classList.remove('sdt-trigger-position-animated');
|
|
445
|
+
}, 180);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function applyPos(nextPos: Position, options?: { animate?: boolean }) {
|
|
450
|
+
setPositionAnimation(options?.animate === true);
|
|
451
|
+
pos = nextPos;
|
|
452
|
+
btn.style.left = pos.left + 'px';
|
|
453
|
+
btn.style.top = pos.top + 'px';
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const btn = h('button', {
|
|
457
|
+
className: 'sdt-trigger',
|
|
458
|
+
'aria-label': 'Toggle Hexclave Dev Tools',
|
|
459
|
+
'data-hexclave-devtool-trigger': 'true',
|
|
460
|
+
title: 'Hexclave Dev Tools',
|
|
461
|
+
});
|
|
462
|
+
const logoSpan = h('span', { className: 'sdt-trigger-logo' });
|
|
463
|
+
setHtml(logoSpan, HEXCLAVE_LOGO_SVG);
|
|
464
|
+
btn.appendChild(logoSpan);
|
|
465
|
+
|
|
466
|
+
let placement = loadPlacement() ?? { corner: 'bottom-right' as TriggerCorner };
|
|
467
|
+
let pos = resolveTriggerPosition(placement, triggerSize, { width: window.innerWidth, height: window.innerHeight });
|
|
468
|
+
applyPos(pos);
|
|
469
|
+
|
|
470
|
+
let dragState: { startX: number; startY: number; startLeft: number; startTop: number; didDrag: boolean } | null = null;
|
|
471
|
+
|
|
472
|
+
// After mount, measure the actual rendered size and re-snap if needed.
|
|
473
|
+
requestAnimationFrame(() => {
|
|
474
|
+
const rect = btn.getBoundingClientRect();
|
|
475
|
+
if (rect.width > 0 && rect.height > 0) {
|
|
476
|
+
triggerSize = { width: rect.width, height: rect.height };
|
|
477
|
+
const measured = resolveTriggerPosition(placement, triggerSize, { width: window.innerWidth, height: window.innerHeight });
|
|
478
|
+
if (measured.left !== pos.left || measured.top !== pos.top) {
|
|
479
|
+
applyPos(measured, { animate: true });
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
btn.addEventListener('pointerdown', (e) => {
|
|
485
|
+
e.preventDefault();
|
|
486
|
+
setPositionAnimation(false);
|
|
487
|
+
btn.setPointerCapture(e.pointerId);
|
|
488
|
+
dragState = { startX: e.clientX, startY: e.clientY, startLeft: pos.left, startTop: pos.top, didDrag: false };
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
btn.addEventListener('pointermove', (e) => {
|
|
492
|
+
if (!dragState) return;
|
|
493
|
+
const dx = e.clientX - dragState.startX;
|
|
494
|
+
const dy = e.clientY - dragState.startY;
|
|
495
|
+
if (!dragState.didDrag && Math.abs(dx) + Math.abs(dy) < DRAG_THRESHOLD) return;
|
|
496
|
+
dragState.didDrag = true;
|
|
497
|
+
applyPos(clampTriggerPosition(
|
|
498
|
+
{ left: dragState.startLeft + dx, top: dragState.startTop + dy },
|
|
499
|
+
triggerSize,
|
|
500
|
+
{ width: window.innerWidth, height: window.innerHeight },
|
|
501
|
+
));
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
btn.addEventListener('pointerup', (e) => {
|
|
505
|
+
const ds = dragState;
|
|
506
|
+
dragState = null;
|
|
507
|
+
if (!ds) return;
|
|
508
|
+
btn.releasePointerCapture(e.pointerId);
|
|
509
|
+
if (ds.didDrag) {
|
|
510
|
+
placement = getSnappedTriggerPlacement(pos, triggerSize, { width: window.innerWidth, height: window.innerHeight });
|
|
511
|
+
applyPos(resolveTriggerPosition(placement, triggerSize, { width: window.innerWidth, height: window.innerHeight }), { animate: true });
|
|
512
|
+
savePlacement(placement);
|
|
513
|
+
} else {
|
|
514
|
+
onClick();
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
// On viewport resize, reapply the existing corner placement to the new dimensions.
|
|
519
|
+
// Placement (corner) only changes when the user drags.
|
|
520
|
+
function onResize() {
|
|
521
|
+
const resizedPos = resolveTriggerPosition(placement, triggerSize, { width: window.innerWidth, height: window.innerHeight });
|
|
522
|
+
if (resizedPos.left !== pos.left || resizedPos.top !== pos.top) {
|
|
523
|
+
applyPos(resizedPos, { animate: true });
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
window.addEventListener('resize', onResize);
|
|
528
|
+
|
|
529
|
+
return {
|
|
530
|
+
element: btn,
|
|
531
|
+
cleanup: () => {
|
|
532
|
+
if (animationTimeout !== null) {
|
|
533
|
+
window.clearTimeout(animationTimeout);
|
|
534
|
+
}
|
|
535
|
+
window.removeEventListener('resize', onResize);
|
|
536
|
+
},
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// ---------------------------------------------------------------------------
|
|
541
|
+
// Tab bar with sliding indicator
|
|
542
|
+
// ---------------------------------------------------------------------------
|
|
543
|
+
|
|
544
|
+
function createTabBar(
|
|
545
|
+
tabs: { id: string; label: string; icon?: string }[],
|
|
546
|
+
activeTab: string,
|
|
547
|
+
onTabChange: (id: string) => void,
|
|
548
|
+
opts?: { variant?: 'bar' | 'pills'; trailing?: HTMLElement },
|
|
549
|
+
): { el: HTMLElement; setActive: (id: string) => void } {
|
|
550
|
+
const variant = opts?.variant ?? 'bar';
|
|
551
|
+
const barClass = variant === 'pills' ? 'sdt-console-tabs' : 'sdt-tabbar';
|
|
552
|
+
const tabClass = variant === 'pills' ? 'sdt-console-tab' : 'sdt-tab';
|
|
553
|
+
const indicatorClass = variant === 'pills' ? 'sdt-console-tab-indicator' : 'sdt-tab-indicator';
|
|
554
|
+
|
|
555
|
+
const bar = h('div', { className: barClass });
|
|
556
|
+
const indicator = h('div', { className: indicatorClass });
|
|
557
|
+
indicator.style.opacity = '0';
|
|
558
|
+
bar.appendChild(indicator);
|
|
559
|
+
|
|
560
|
+
let current = activeTab;
|
|
561
|
+
let isInitial = true;
|
|
562
|
+
|
|
563
|
+
const buttons = tabs.map((tab) => {
|
|
564
|
+
const btn = h('button', {
|
|
565
|
+
className: tabClass,
|
|
566
|
+
'data-tab-id': tab.id,
|
|
567
|
+
'data-active': String(tab.id === activeTab),
|
|
568
|
+
});
|
|
569
|
+
if (tab.icon) {
|
|
570
|
+
const iconSpan = h('span', { className: 'sdt-tab-icon' });
|
|
571
|
+
setHtml(iconSpan, tab.icon);
|
|
572
|
+
btn.appendChild(iconSpan);
|
|
573
|
+
}
|
|
574
|
+
btn.appendChild(document.createTextNode(tab.label));
|
|
575
|
+
btn.addEventListener('click', () => onTabChange(tab.id));
|
|
576
|
+
bar.appendChild(btn);
|
|
577
|
+
return btn;
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
if (variant === 'bar') {
|
|
581
|
+
bar.appendChild(h('div', { className: 'sdt-tabbar-spacer' }));
|
|
582
|
+
}
|
|
583
|
+
if (opts?.trailing) {
|
|
584
|
+
bar.appendChild(opts.trailing);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function measure() {
|
|
588
|
+
const btn = bar.querySelector<HTMLElement>(`[data-tab-id="${current}"]`);
|
|
589
|
+
if (!btn) return;
|
|
590
|
+
indicator.style.transform = `translateX(${btn.offsetLeft}px)`;
|
|
591
|
+
indicator.style.width = btn.offsetWidth + 'px';
|
|
592
|
+
indicator.style.height = btn.offsetHeight + 'px';
|
|
593
|
+
indicator.style.opacity = '1';
|
|
594
|
+
indicator.style.transition = isInitial ? 'none' : '';
|
|
595
|
+
isInitial = false;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
const ro = new ResizeObserver(measure);
|
|
599
|
+
ro.observe(bar);
|
|
600
|
+
requestAnimationFrame(measure);
|
|
601
|
+
|
|
602
|
+
function setActive(id: string) {
|
|
603
|
+
current = id;
|
|
604
|
+
buttons.forEach((btn) => {
|
|
605
|
+
const tabId = btn.getAttribute('data-tab-id');
|
|
606
|
+
btn.setAttribute('data-active', String(tabId === id));
|
|
607
|
+
});
|
|
608
|
+
measure();
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
return { el: bar, setActive };
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// ---------------------------------------------------------------------------
|
|
615
|
+
// Iframe helper
|
|
616
|
+
// ---------------------------------------------------------------------------
|
|
617
|
+
|
|
618
|
+
function createIframeTab(src: string, title: string, loadingMsg = 'Loading\u2026', errorMsg = 'Unable to load content', errorDetail?: string, openExternallyLabel?: string): HTMLElement {
|
|
619
|
+
const container = h('div', { className: 'sdt-iframe-container' });
|
|
620
|
+
if (openExternallyLabel != null) {
|
|
621
|
+
container.appendChild(h('div', { className: 'sdt-iframe-toolbar' },
|
|
622
|
+
h('a', { href: src, target: '_blank', rel: 'noopener noreferrer', className: 'sdt-iframe-open-link' }, openExternallyLabel),
|
|
623
|
+
));
|
|
624
|
+
}
|
|
625
|
+
const loadingEl = h('div', { className: 'sdt-iframe-loading' }, loadingMsg);
|
|
626
|
+
container.appendChild(loadingEl);
|
|
627
|
+
|
|
628
|
+
const iframe = document.createElement('iframe');
|
|
629
|
+
iframe.src = src;
|
|
630
|
+
iframe.title = title;
|
|
631
|
+
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-popups allow-forms');
|
|
632
|
+
iframe.style.display = 'none';
|
|
633
|
+
|
|
634
|
+
iframe.addEventListener('load', () => {
|
|
635
|
+
loadingEl.style.display = 'none';
|
|
636
|
+
iframe.style.display = 'block';
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
iframe.addEventListener('error', () => {
|
|
640
|
+
loadingEl.style.display = 'none';
|
|
641
|
+
container.innerHTML = '';
|
|
642
|
+
const errDiv = h('div', { className: 'sdt-iframe-error' });
|
|
643
|
+
errDiv.appendChild(h('div', null, errorMsg));
|
|
644
|
+
if (errorDetail) {
|
|
645
|
+
errDiv.appendChild(h('div', { style: { fontSize: '12px', color: 'var(--sdt-text-tertiary)' } }, errorDetail));
|
|
646
|
+
}
|
|
647
|
+
const retryBtn = h('button', { className: 'sdt-iframe-error-btn' }, 'Retry');
|
|
648
|
+
retryBtn.addEventListener('click', () => {
|
|
649
|
+
container.replaceWith(createIframeTab(src, title, loadingMsg, errorMsg, errorDetail, openExternallyLabel));
|
|
650
|
+
});
|
|
651
|
+
errDiv.appendChild(retryBtn);
|
|
652
|
+
const link = h('a', { href: src, target: '_blank', rel: 'noopener noreferrer', style: { color: 'var(--sdt-accent)', fontSize: '12px', textDecoration: 'none' } }, 'Open in new tab');
|
|
653
|
+
errDiv.appendChild(link);
|
|
654
|
+
container.appendChild(errDiv);
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
container.appendChild(iframe);
|
|
658
|
+
return container;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// ===========================================================================================
|
|
662
|
+
// TABS
|
|
663
|
+
// ===========================================================================================
|
|
664
|
+
|
|
665
|
+
// ---------------------------------------------------------------------------
|
|
666
|
+
// Overview tab
|
|
667
|
+
// ---------------------------------------------------------------------------
|
|
668
|
+
|
|
669
|
+
function createOverviewTab(app: StackClientApp<true>): TabResult {
|
|
670
|
+
const container = h('div', { className: 'sdt-ov' });
|
|
671
|
+
|
|
672
|
+
// ── Identity card ──────────────────────────────────────────────────────────
|
|
673
|
+
const heroCard = h('div', { className: 'sdt-ov-card sdt-ov-card-hero' });
|
|
674
|
+
heroCard.appendChild(h('div', { className: 'sdt-ov-label' }, 'Identity'));
|
|
675
|
+
|
|
676
|
+
const userRow = h('div', { className: 'sdt-ov-user-row' });
|
|
677
|
+
const avatar = h('div', { className: 'sdt-ov-avatar' }, '?');
|
|
678
|
+
const userMeta = h('div', { className: 'sdt-ov-user-meta' });
|
|
679
|
+
const userName = h('div', { className: 'sdt-ov-user-name' }, 'Loading\u2026');
|
|
680
|
+
const userEmail = h('div', { className: 'sdt-ov-user-email' }, '');
|
|
681
|
+
const authIndicator = h('div', { className: 'sdt-ov-auth-indicator', style: { display: 'none' } }, 'Authenticated');
|
|
682
|
+
userMeta.append(userName, userEmail, authIndicator);
|
|
683
|
+
userRow.append(avatar, userMeta);
|
|
684
|
+
heroCard.appendChild(userRow);
|
|
685
|
+
|
|
686
|
+
const actions = h('div', { className: 'sdt-ov-actions' });
|
|
687
|
+
const toast = h('div', { className: 'sdt-ov-toast', style: { display: 'none' } });
|
|
688
|
+
const emailRow = h('div', { className: 'sdt-ov-email-input' });
|
|
689
|
+
const emailInput = h('input', { type: 'email', placeholder: 'Sign in as email\u2026' }) as HTMLInputElement;
|
|
690
|
+
const emailBtn = h('button', null);
|
|
691
|
+
setHtml(emailBtn, '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg>');
|
|
692
|
+
emailRow.append(emailInput, emailBtn);
|
|
693
|
+
|
|
694
|
+
function isBestEffortOverviewError(error: unknown) {
|
|
695
|
+
if (error instanceof DOMException && error.name === 'AbortError') {
|
|
696
|
+
return true;
|
|
697
|
+
}
|
|
698
|
+
if (error instanceof TypeError) {
|
|
699
|
+
return true;
|
|
700
|
+
}
|
|
701
|
+
if (error instanceof Error) {
|
|
702
|
+
return error.message.includes('Failed to fetch')
|
|
703
|
+
|| error.message.includes('NetworkError')
|
|
704
|
+
|| error.message.includes('Load failed')
|
|
705
|
+
|| error.message.includes('network connection');
|
|
706
|
+
}
|
|
707
|
+
return false;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
function showToast(msg: string, type: 'success' | 'error') {
|
|
711
|
+
toast.textContent = msg;
|
|
712
|
+
toast.className = `sdt-ov-toast sdt-ov-toast-${type}`;
|
|
713
|
+
toast.style.display = '';
|
|
714
|
+
setTimeout(() => {
|
|
715
|
+
toast.style.display = 'none';
|
|
716
|
+
}, 4000);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
let currentUser: any = null;
|
|
720
|
+
let loading = false;
|
|
721
|
+
|
|
722
|
+
function rebuildActions() {
|
|
723
|
+
actions.innerHTML = '';
|
|
724
|
+
if (currentUser) {
|
|
725
|
+
const signOutBtn = h('button', { className: 'sdt-ov-btn sdt-ov-btn-danger' }, 'Sign Out');
|
|
726
|
+
signOutBtn.disabled = loading;
|
|
727
|
+
signOutBtn.addEventListener('click', () => {
|
|
728
|
+
runAsynchronously(async () => {
|
|
729
|
+
loading = true;
|
|
730
|
+
rebuildActions();
|
|
731
|
+
try {
|
|
732
|
+
await currentUser.signOut();
|
|
733
|
+
showToast('Signed out', 'success');
|
|
734
|
+
} catch (e: any) {
|
|
735
|
+
showToast(e.message || 'Sign out failed', 'error');
|
|
736
|
+
}
|
|
737
|
+
loading = false;
|
|
738
|
+
await refreshUser();
|
|
739
|
+
});
|
|
740
|
+
});
|
|
741
|
+
const randomBtn = h('button', { className: 'sdt-ov-btn sdt-ov-btn-primary' }, 'Random User');
|
|
742
|
+
randomBtn.disabled = loading;
|
|
743
|
+
randomBtn.addEventListener('click', () => {
|
|
744
|
+
runAsynchronously(doQuickSignIn());
|
|
745
|
+
});
|
|
746
|
+
actions.append(signOutBtn, randomBtn);
|
|
747
|
+
} else {
|
|
748
|
+
const quickBtn = h('button', { className: 'sdt-ov-btn sdt-ov-btn-primary sdt-ov-btn-wide' }, loading ? 'Working\u2026' : 'Quick Sign In');
|
|
749
|
+
quickBtn.disabled = loading;
|
|
750
|
+
quickBtn.addEventListener('click', () => {
|
|
751
|
+
runAsynchronously(doQuickSignIn());
|
|
752
|
+
});
|
|
753
|
+
actions.appendChild(quickBtn);
|
|
754
|
+
}
|
|
755
|
+
emailInput.placeholder = currentUser ? 'Switch to email\u2026' : 'Sign in as email\u2026';
|
|
756
|
+
actions.appendChild(emailRow);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
async function doQuickSignIn() {
|
|
760
|
+
if (!isLocalhost(window.location.href)) {
|
|
761
|
+
showToast('Quick sign-in is only available on localhost', 'error');
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
loading = true;
|
|
765
|
+
rebuildActions();
|
|
766
|
+
const email = generateRandomEmail();
|
|
767
|
+
try {
|
|
768
|
+
const signUpResult = await app.signUpWithCredential({ email, password: email, noRedirect: true } as any);
|
|
769
|
+
if (signUpResult.status === 'error') {
|
|
770
|
+
showToast(`Sign up failed: ${signUpResult.error.message}`, 'error');
|
|
771
|
+
loading = false;
|
|
772
|
+
rebuildActions();
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
const signInResult = await app.signInWithCredential({ email, password: email, noRedirect: true });
|
|
776
|
+
if (signInResult.status === 'error') {
|
|
777
|
+
showToast(`Sign in failed: ${signInResult.error.message}`, 'error');
|
|
778
|
+
} else {
|
|
779
|
+
showToast(`Signed in as ${email}`, 'success');
|
|
780
|
+
}
|
|
781
|
+
} catch (e: any) {
|
|
782
|
+
showToast(e.message || 'Unknown error', 'error');
|
|
783
|
+
}
|
|
784
|
+
loading = false;
|
|
785
|
+
await refreshUser();
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
async function doSignInAs(targetEmail: string) {
|
|
789
|
+
if (!targetEmail.trim()) return;
|
|
790
|
+
if (!isLocalhost(window.location.href)) {
|
|
791
|
+
showToast('Quick sign-in is only available on localhost', 'error');
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
loading = true;
|
|
795
|
+
rebuildActions();
|
|
796
|
+
const trimmed = targetEmail.trim();
|
|
797
|
+
try {
|
|
798
|
+
const signInResult = await app.signInWithCredential({ email: trimmed, password: trimmed, noRedirect: true });
|
|
799
|
+
if (signInResult.status === 'ok') {
|
|
800
|
+
showToast(`Signed in as ${trimmed}`, 'success');
|
|
801
|
+
emailInput.value = '';
|
|
802
|
+
loading = false;
|
|
803
|
+
await refreshUser();
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
const signUpResult = await app.signUpWithCredential({ email: trimmed, password: trimmed, noRedirect: true } as any);
|
|
807
|
+
if (signUpResult.status === 'error') {
|
|
808
|
+
showToast(`Failed: ${signUpResult.error.message}`, 'error');
|
|
809
|
+
loading = false;
|
|
810
|
+
rebuildActions();
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
const retryResult = await app.signInWithCredential({ email: trimmed, password: trimmed, noRedirect: true });
|
|
814
|
+
if (retryResult.status === 'error') {
|
|
815
|
+
showToast(`Sign in failed: ${retryResult.error.message}`, 'error');
|
|
816
|
+
} else {
|
|
817
|
+
showToast(`Signed in as ${trimmed}`, 'success');
|
|
818
|
+
emailInput.value = '';
|
|
819
|
+
}
|
|
820
|
+
} catch (e: any) {
|
|
821
|
+
showToast(e.message || 'Unknown error', 'error');
|
|
822
|
+
}
|
|
823
|
+
loading = false;
|
|
824
|
+
await refreshUser();
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
emailBtn.addEventListener('click', () => {
|
|
828
|
+
runAsynchronously(doSignInAs(emailInput.value));
|
|
829
|
+
});
|
|
830
|
+
emailInput.addEventListener('keydown', (e) => {
|
|
831
|
+
if (e.key === 'Enter') {
|
|
832
|
+
runAsynchronously(doSignInAs(emailInput.value));
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
heroCard.append(actions, toast);
|
|
837
|
+
|
|
838
|
+
// ── Auth methods card ──────────────────────────────────────────────────────
|
|
839
|
+
const methodsCard = h('div', { className: 'sdt-ov-card sdt-ov-card-auth' });
|
|
840
|
+
methodsCard.appendChild(h('div', { className: 'sdt-ov-label' }, 'Auth Methods'));
|
|
841
|
+
const authGrid = h('div', { className: 'sdt-ov-auth-grid' });
|
|
842
|
+
for (let i = 0; i < 3; i++) {
|
|
843
|
+
authGrid.appendChild(h('div', { className: 'sdt-ov-method sdt-ov-skeleton-pill' }));
|
|
844
|
+
}
|
|
845
|
+
methodsCard.appendChild(authGrid);
|
|
846
|
+
let hasActiveAuthMethod: boolean | null = null;
|
|
847
|
+
|
|
848
|
+
async function loadAuthMethods() {
|
|
849
|
+
try {
|
|
850
|
+
const project = await app.getProject();
|
|
851
|
+
authGrid.innerHTML = '';
|
|
852
|
+
const config = project.config;
|
|
853
|
+
hasActiveAuthMethod = config.credentialEnabled
|
|
854
|
+
|| config.magicLinkEnabled
|
|
855
|
+
|| config.passkeyEnabled
|
|
856
|
+
|| config.oauthProviders.length > 0;
|
|
857
|
+
const methods = [
|
|
858
|
+
{ label: 'Password', enabled: config.credentialEnabled },
|
|
859
|
+
{ label: 'Magic Link', enabled: config.magicLinkEnabled },
|
|
860
|
+
{ label: 'Passkey', enabled: config.passkeyEnabled },
|
|
861
|
+
];
|
|
862
|
+
for (const m of methods) {
|
|
863
|
+
const pill = h('div', { className: `sdt-ov-method ${m.enabled ? 'sdt-ov-method-on' : 'sdt-ov-method-off'}` });
|
|
864
|
+
pill.appendChild(h('span', { className: 'sdt-ov-method-name' }, m.label));
|
|
865
|
+
authGrid.appendChild(pill);
|
|
866
|
+
}
|
|
867
|
+
for (const p of config.oauthProviders) {
|
|
868
|
+
const pill = h('div', { className: 'sdt-ov-method sdt-ov-method-on sdt-ov-method-oauth' });
|
|
869
|
+
pill.appendChild(h('span', { className: 'sdt-ov-method-name' }, p.id));
|
|
870
|
+
authGrid.appendChild(pill);
|
|
871
|
+
}
|
|
872
|
+
if (!config.signUpEnabled) {
|
|
873
|
+
const pill = h('div', { className: 'sdt-ov-method sdt-ov-method-warn' });
|
|
874
|
+
pill.appendChild(h('span', { className: 'sdt-ov-method-name' }, 'Sign-up off'));
|
|
875
|
+
authGrid.appendChild(pill);
|
|
876
|
+
}
|
|
877
|
+
buildChecklist();
|
|
878
|
+
} catch (error) {
|
|
879
|
+
authGrid.innerHTML = '<div style="font-size:11px;color:var(--sdt-text-tertiary)">Could not load auth methods</div>';
|
|
880
|
+
hasActiveAuthMethod = null;
|
|
881
|
+
buildChecklist();
|
|
882
|
+
if (!isBestEffortOverviewError(error)) {
|
|
883
|
+
throw error;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// Overview hydration is best-effort while the local Stack backend is still booting.
|
|
889
|
+
runAsynchronously(loadAuthMethods());
|
|
890
|
+
|
|
891
|
+
// ── Setup checklist (only shown when something is incomplete) ──────────────
|
|
892
|
+
const checksCard = h('div', { className: 'sdt-ov-card sdt-ov-card-checks' });
|
|
893
|
+
const projectId = app.projectId;
|
|
894
|
+
let checksCardMounted = false;
|
|
895
|
+
|
|
896
|
+
function buildChecklist() {
|
|
897
|
+
checksCard.innerHTML = '';
|
|
898
|
+
const checks = [
|
|
899
|
+
{ ok: !!projectId && projectId !== 'default', label: 'Project configured', hint: null },
|
|
900
|
+
{ ok: hasActiveAuthMethod === true, label: 'Auth method active', hint: hasActiveAuthMethod === null ? 'Still checking project config' : null },
|
|
901
|
+
{ ok: !!currentUser, label: 'Sign in a test user', hint: 'Use \u201cQuick Sign In\u201d above \u2192' },
|
|
902
|
+
];
|
|
903
|
+
const passCount = checks.filter((c) => c.ok).length;
|
|
904
|
+
const allGood = passCount === checks.length;
|
|
905
|
+
|
|
906
|
+
if (allGood) {
|
|
907
|
+
if (checksCardMounted && checksCard.parentElement) {
|
|
908
|
+
container.removeChild(checksCard);
|
|
909
|
+
checksCardMounted = false;
|
|
910
|
+
}
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
if (!checksCardMounted) {
|
|
915
|
+
container.appendChild(checksCard);
|
|
916
|
+
checksCardMounted = true;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
const titleRow = h('div', { className: 'sdt-ov-checks-header' });
|
|
920
|
+
const titleLabel = h('div', { className: 'sdt-ov-label', style: { marginBottom: '0', color: 'var(--sdt-warning)' } }, 'Setup');
|
|
921
|
+
const badge = h('span', { className: 'sdt-ov-checks-badge sdt-ov-checks-badge-warn' }, `${passCount}\u200a/\u200a${checks.length}`);
|
|
922
|
+
titleRow.append(titleLabel, badge);
|
|
923
|
+
checksCard.appendChild(titleRow);
|
|
924
|
+
|
|
925
|
+
const bar = h('div', { className: 'sdt-ov-checks-bar' });
|
|
926
|
+
const fill = h('div', { className: 'sdt-ov-checks-bar-fill' });
|
|
927
|
+
fill.style.width = `${(passCount / checks.length) * 100}%`;
|
|
928
|
+
bar.appendChild(fill);
|
|
929
|
+
checksCard.appendChild(bar);
|
|
930
|
+
|
|
931
|
+
for (const c of checks) {
|
|
932
|
+
const row = h('div', { className: 'sdt-ov-setup-row' });
|
|
933
|
+
row.appendChild(h('span', { className: `sdt-ov-setup-dot ${c.ok ? 'sdt-ov-setup-dot-ok' : 'sdt-ov-setup-dot-warn'}` }));
|
|
934
|
+
row.appendChild(h('span', { className: 'sdt-ov-setup-label' }, c.label));
|
|
935
|
+
if (!c.ok && c.hint) {
|
|
936
|
+
row.appendChild(h('span', { className: 'sdt-ov-setup-hint' }, c.hint));
|
|
937
|
+
}
|
|
938
|
+
checksCard.appendChild(row);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
async function refreshUser() {
|
|
943
|
+
try {
|
|
944
|
+
currentUser = await app.getUser();
|
|
945
|
+
|
|
946
|
+
if (currentUser) {
|
|
947
|
+
const initials = (currentUser.displayName || currentUser.primaryEmail || '?')
|
|
948
|
+
.split(' ').map((s: string) => s[0]).join('').slice(0, 2).toUpperCase();
|
|
949
|
+
avatar.className = 'sdt-ov-avatar sdt-ov-avatar-active';
|
|
950
|
+
if (currentUser.profileImageUrl) {
|
|
951
|
+
avatar.innerHTML = `<img src="${escapeHtml(currentUser.profileImageUrl)}" alt="" />`;
|
|
952
|
+
} else {
|
|
953
|
+
avatar.textContent = initials;
|
|
954
|
+
}
|
|
955
|
+
userName.textContent = currentUser.displayName || 'Anonymous';
|
|
956
|
+
userEmail.textContent = currentUser.primaryEmail || 'No email';
|
|
957
|
+
authIndicator.style.display = '';
|
|
958
|
+
} else {
|
|
959
|
+
avatar.className = 'sdt-ov-avatar';
|
|
960
|
+
avatar.textContent = '?';
|
|
961
|
+
userName.textContent = 'No user signed in';
|
|
962
|
+
userEmail.textContent = 'Sign in to test auth flows';
|
|
963
|
+
authIndicator.style.display = 'none';
|
|
964
|
+
}
|
|
965
|
+
} catch (error) {
|
|
966
|
+
avatar.className = 'sdt-ov-avatar';
|
|
967
|
+
avatar.textContent = '?';
|
|
968
|
+
userName.textContent = 'Could not load user';
|
|
969
|
+
userEmail.textContent = 'Check your local Stack backend';
|
|
970
|
+
authIndicator.style.display = 'none';
|
|
971
|
+
currentUser = null;
|
|
972
|
+
if (!isBestEffortOverviewError(error)) {
|
|
973
|
+
throw error;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
rebuildActions();
|
|
977
|
+
buildChecklist();
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
container.append(heroCard, methodsCard);
|
|
981
|
+
buildChecklist();
|
|
982
|
+
runAsynchronously(refreshUser());
|
|
983
|
+
const userPoll = setInterval(() => {
|
|
984
|
+
runAsynchronously(refreshUser());
|
|
985
|
+
}, 3000);
|
|
986
|
+
|
|
987
|
+
return { element: container, cleanup: () => clearInterval(userPoll) };
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
// ---------------------------------------------------------------------------
|
|
991
|
+
// Console tab
|
|
992
|
+
// ---------------------------------------------------------------------------
|
|
993
|
+
|
|
994
|
+
type MergedLogEntry =
|
|
995
|
+
| { kind: 'api', entry: ApiLogEntry }
|
|
996
|
+
| { kind: 'event', entry: EventLogEntry };
|
|
997
|
+
|
|
998
|
+
function createConsoleTab(logStore: LogStore): TabResult {
|
|
999
|
+
const container = h('div', { className: 'sdt-console-panel' });
|
|
1000
|
+
|
|
1001
|
+
const EVENT_TYPE_STYLES: Record<string, string> = {
|
|
1002
|
+
'error': 'sdt-badge-error',
|
|
1003
|
+
'info': 'sdt-badge-info',
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
const title = h('div', { className: 'sdt-console-title' }, 'Logs');
|
|
1007
|
+
const actions = h('div', { className: 'sdt-console-actions' });
|
|
1008
|
+
const copyBtn = h('button', { className: 'sdt-console-action-btn', title: 'Copy logs' });
|
|
1009
|
+
setHtml(copyBtn, '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>Copy');
|
|
1010
|
+
const exportBtn = h('button', { className: 'sdt-console-action-btn', title: 'Export logs' });
|
|
1011
|
+
setHtml(exportBtn, '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>Export');
|
|
1012
|
+
const clearBtn = h('button', { className: 'sdt-console-action-btn', title: 'Clear logs' });
|
|
1013
|
+
setHtml(clearBtn, '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/></svg>Clear');
|
|
1014
|
+
actions.append(copyBtn, exportBtn, clearBtn);
|
|
1015
|
+
container.appendChild(h('div', { className: 'sdt-console-header' }, title, actions));
|
|
1016
|
+
|
|
1017
|
+
const contentArea = h('div', { className: 'sdt-console-log-scroll sdt-tab-content-fade' });
|
|
1018
|
+
container.appendChild(contentArea);
|
|
1019
|
+
|
|
1020
|
+
let visibleLogCount = CONSOLE_LOG_BATCH_SIZE;
|
|
1021
|
+
|
|
1022
|
+
function getMergedLogs(): MergedLogEntry[] {
|
|
1023
|
+
return [
|
|
1024
|
+
...logStore.apiLogs.map((entry) => ({ kind: 'api' as const, entry })),
|
|
1025
|
+
...logStore.eventLogs.map((entry) => ({ kind: 'event' as const, entry })),
|
|
1026
|
+
].sort((a, b) => b.entry.timestamp - a.entry.timestamp);
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
function formatLogLine(item: MergedLogEntry): string {
|
|
1030
|
+
if (item.kind === 'api') {
|
|
1031
|
+
const log = item.entry;
|
|
1032
|
+
const status = log.status !== undefined ? ` [${log.status}]` : '';
|
|
1033
|
+
const duration = log.duration !== undefined ? ` ${log.duration}ms` : '';
|
|
1034
|
+
const error = log.error !== undefined ? ` ${log.error}` : '';
|
|
1035
|
+
return `${new Date(log.timestamp).toISOString()} ${log.method} ${log.url}${status}${duration}${error}`;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
const log = item.entry;
|
|
1039
|
+
return `${new Date(log.timestamp).toISOString()} ${log.type.toUpperCase()} ${log.message}`;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
function formatLogsForExport(): string {
|
|
1043
|
+
const lines = [
|
|
1044
|
+
'=== Hexclave Dev Tool Logs ===',
|
|
1045
|
+
`Generated: ${new Date().toISOString()}`,
|
|
1046
|
+
`Total logs: ${getMergedLogs().length}`,
|
|
1047
|
+
'',
|
|
1048
|
+
...getMergedLogs().map(formatLogLine),
|
|
1049
|
+
];
|
|
1050
|
+
return lines.join('\n');
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
function renderLogItem(item: MergedLogEntry): HTMLElement {
|
|
1054
|
+
if (item.kind === 'api') {
|
|
1055
|
+
const log = item.entry;
|
|
1056
|
+
const row = h('div', { className: 'sdt-log-item' });
|
|
1057
|
+
row.appendChild(h('span', { className: 'sdt-log-time' }, formatTimestamp(log.timestamp)));
|
|
1058
|
+
row.appendChild(h('span', { className: `sdt-log-method sdt-log-method-${log.method.toLowerCase()}` }, log.method));
|
|
1059
|
+
row.appendChild(h('span', { className: 'sdt-log-url' }, log.url));
|
|
1060
|
+
if (log.status !== undefined) {
|
|
1061
|
+
row.appendChild(h('span', { className: `sdt-log-status ${log.status < 400 ? 'sdt-log-status-ok' : 'sdt-log-status-err'}` }, String(log.status)));
|
|
1062
|
+
}
|
|
1063
|
+
if (log.duration !== undefined) {
|
|
1064
|
+
row.appendChild(h('span', { className: 'sdt-log-time' }, log.duration + 'ms'));
|
|
1065
|
+
}
|
|
1066
|
+
return row;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
const log = item.entry;
|
|
1070
|
+
const row = h('div', { className: 'sdt-log-item' });
|
|
1071
|
+
row.appendChild(h('span', { className: 'sdt-log-time' }, formatTimestamp(log.timestamp)));
|
|
1072
|
+
row.appendChild(h('span', { className: `sdt-badge ${EVENT_TYPE_STYLES[log.type] || 'sdt-badge-info'}` }, log.type));
|
|
1073
|
+
row.appendChild(h('span', { className: 'sdt-log-message' }, log.message));
|
|
1074
|
+
return row;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
function renderLogs() {
|
|
1078
|
+
const previousScrollTop = contentArea.scrollTop;
|
|
1079
|
+
contentArea.innerHTML = '';
|
|
1080
|
+
const merged = getMergedLogs();
|
|
1081
|
+
visibleLogCount = Math.min(Math.max(visibleLogCount, CONSOLE_LOG_BATCH_SIZE), Math.max(merged.length, CONSOLE_LOG_BATCH_SIZE));
|
|
1082
|
+
|
|
1083
|
+
if (merged.length === 0) {
|
|
1084
|
+
contentArea.innerHTML = '<div class="sdt-empty-state"><div class="sdt-empty-state-icon">\uD83D\uDCCB</div><div>No logs recorded yet</div><div style="font-size:12px;color:var(--sdt-text-tertiary)">API calls and auth events will appear here</div></div>';
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
const list = h('div', { className: 'sdt-log-list' });
|
|
1089
|
+
for (const item of merged.slice(0, visibleLogCount)) {
|
|
1090
|
+
list.appendChild(renderLogItem(item));
|
|
1091
|
+
}
|
|
1092
|
+
if (visibleLogCount < merged.length) {
|
|
1093
|
+
list.appendChild(h('div', { className: 'sdt-log-load-hint' }, `${merged.length - visibleLogCount} older logs available`));
|
|
1094
|
+
}
|
|
1095
|
+
contentArea.appendChild(list);
|
|
1096
|
+
contentArea.scrollTop = Math.min(previousScrollTop, contentArea.scrollHeight);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
function maybeLoadOlderLogs() {
|
|
1100
|
+
const mergedLength = getMergedLogs().length;
|
|
1101
|
+
if (visibleLogCount >= mergedLength) return;
|
|
1102
|
+
const distanceFromBottom = contentArea.scrollHeight - contentArea.scrollTop - contentArea.clientHeight;
|
|
1103
|
+
if (distanceFromBottom <= 48) {
|
|
1104
|
+
visibleLogCount = Math.min(visibleLogCount + CONSOLE_LOG_BATCH_SIZE, mergedLength);
|
|
1105
|
+
renderLogs();
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
contentArea.addEventListener('scroll', maybeLoadOlderLogs);
|
|
1110
|
+
renderLogs();
|
|
1111
|
+
|
|
1112
|
+
copyBtn.addEventListener('click', () => {
|
|
1113
|
+
runAsynchronously(
|
|
1114
|
+
navigator.clipboard.writeText(formatLogsForExport()).then(() => {
|
|
1115
|
+
copyBtn.textContent = '\u2713 Copied';
|
|
1116
|
+
setTimeout(() => {
|
|
1117
|
+
setHtml(copyBtn, '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>Copy');
|
|
1118
|
+
}, 1500);
|
|
1119
|
+
})
|
|
1120
|
+
);
|
|
1121
|
+
});
|
|
1122
|
+
|
|
1123
|
+
exportBtn.addEventListener('click', () => {
|
|
1124
|
+
const blob = new Blob([formatLogsForExport()], { type: 'text/plain;charset=utf-8' });
|
|
1125
|
+
const url = URL.createObjectURL(blob);
|
|
1126
|
+
const link = h('a', { href: url, download: `hexclave-dev-tool-logs-${new Date().toISOString()}.txt` });
|
|
1127
|
+
document.body.appendChild(link);
|
|
1128
|
+
link.click();
|
|
1129
|
+
link.remove();
|
|
1130
|
+
URL.revokeObjectURL(url);
|
|
1131
|
+
});
|
|
1132
|
+
|
|
1133
|
+
clearBtn.addEventListener('click', () => {
|
|
1134
|
+
visibleLogCount = CONSOLE_LOG_BATCH_SIZE;
|
|
1135
|
+
logStore.clear();
|
|
1136
|
+
});
|
|
1137
|
+
|
|
1138
|
+
const unsub = logStore.subscribe(() => {
|
|
1139
|
+
renderLogs();
|
|
1140
|
+
});
|
|
1141
|
+
|
|
1142
|
+
return {
|
|
1143
|
+
element: container,
|
|
1144
|
+
cleanup: () => {
|
|
1145
|
+
contentArea.removeEventListener('scroll', maybeLoadOlderLogs);
|
|
1146
|
+
unsub();
|
|
1147
|
+
},
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
// ---------------------------------------------------------------------------
|
|
1152
|
+
// AI tab
|
|
1153
|
+
// ---------------------------------------------------------------------------
|
|
1154
|
+
|
|
1155
|
+
function createAITab(app: StackClientApp<true>): HTMLElement {
|
|
1156
|
+
const container = h('div', { className: 'sdt-ai-container' });
|
|
1157
|
+
const apiBaseUrl = resolveApiBaseUrl(app);
|
|
1158
|
+
|
|
1159
|
+
type ToolCallState = 'running' | 'success' | 'error';
|
|
1160
|
+
type ToolCall = {
|
|
1161
|
+
id: string,
|
|
1162
|
+
toolName: string,
|
|
1163
|
+
argsText: string | null,
|
|
1164
|
+
resultText: string | null,
|
|
1165
|
+
state: ToolCallState,
|
|
1166
|
+
errorText: string | null,
|
|
1167
|
+
isExpanded: boolean,
|
|
1168
|
+
};
|
|
1169
|
+
type AssistantPart =
|
|
1170
|
+
| { type: 'text', content: string }
|
|
1171
|
+
| { type: 'tool', toolCallId: string };
|
|
1172
|
+
type UserMessage = { role: 'user'; content: string };
|
|
1173
|
+
type AssistantMessage = { role: 'assistant'; parts: AssistantPart[]; toolCallsById: Map<string, ToolCall> };
|
|
1174
|
+
type Message = UserMessage | AssistantMessage;
|
|
1175
|
+
const messages: Message[] = [];
|
|
1176
|
+
let aiLoading = false;
|
|
1177
|
+
let activeAiAbortController: AbortController | null = null;
|
|
1178
|
+
|
|
1179
|
+
const messagesArea = h('div', { className: 'sdt-ai-messages' });
|
|
1180
|
+
const inputArea = h('div', { className: 'sdt-ai-input-area' });
|
|
1181
|
+
|
|
1182
|
+
const SUGGESTED_QUESTIONS = [
|
|
1183
|
+
{ icon: '\uD83D\uDD12', text: 'How do I protect a Next.js route?' },
|
|
1184
|
+
{ icon: '\uD83D\uDC65', text: 'How do teams and permissions work?' },
|
|
1185
|
+
{ icon: '\uD83D\uDD17', text: 'How do I add OAuth providers?' },
|
|
1186
|
+
{ icon: '\u2709\uFE0F', text: 'How do I customize auth emails?' },
|
|
1187
|
+
];
|
|
1188
|
+
|
|
1189
|
+
function getHeaders(): Record<string, string> {
|
|
1190
|
+
const opts = app[hexclaveAppInternalsSymbol].getConstructorOptions();
|
|
1191
|
+
// Hexclave rebrand: emit x-hexclave-* request headers (backend dual-accepts).
|
|
1192
|
+
const headers: Record<string, string> = {
|
|
1193
|
+
'X-Hexclave-Access-Type': 'client',
|
|
1194
|
+
'X-Hexclave-Project-Id': app.projectId,
|
|
1195
|
+
};
|
|
1196
|
+
if ('publishableClientKey' in opts && opts.publishableClientKey) {
|
|
1197
|
+
headers['X-Hexclave-Publishable-Client-Key'] = opts.publishableClientKey as string;
|
|
1198
|
+
}
|
|
1199
|
+
return headers;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
function renderToolCard(toolCall: ToolCall): HTMLElement {
|
|
1203
|
+
const toolCard = h('div', { className: 'sdt-ai-tool-card' });
|
|
1204
|
+
const header = h('button', { className: 'sdt-ai-tool-header', type: 'button' });
|
|
1205
|
+
header.appendChild(h('span', { className: 'sdt-ai-tool-name' }, toolCall.toolName));
|
|
1206
|
+
header.appendChild(h('span', { className: `sdt-ai-tool-status sdt-ai-tool-status-${toolCall.state}` }, toolCall.state));
|
|
1207
|
+
header.appendChild(h('span', { className: `sdt-ai-tool-chevron${toolCall.isExpanded ? ' sdt-ai-tool-chevron-open' : ''}` }, '\u25BE'));
|
|
1208
|
+
header.addEventListener('click', () => {
|
|
1209
|
+
toolCall.isExpanded = !toolCall.isExpanded;
|
|
1210
|
+
renderMessages();
|
|
1211
|
+
});
|
|
1212
|
+
toolCard.appendChild(header);
|
|
1213
|
+
|
|
1214
|
+
if (toolCall.isExpanded) {
|
|
1215
|
+
const body = h('div', { className: 'sdt-ai-tool-body' });
|
|
1216
|
+
if (toolCall.argsText !== null) {
|
|
1217
|
+
body.appendChild(h('div', { className: 'sdt-ai-tool-label' }, 'Args'));
|
|
1218
|
+
const argsPre = h('pre', { className: 'sdt-ai-tool-pre' });
|
|
1219
|
+
argsPre.appendChild(h('code', null, toolCall.argsText));
|
|
1220
|
+
body.appendChild(argsPre);
|
|
1221
|
+
}
|
|
1222
|
+
if (toolCall.resultText !== null) {
|
|
1223
|
+
body.appendChild(h('div', { className: 'sdt-ai-tool-label' }, toolCall.state === 'error' ? 'Error' : 'Result'));
|
|
1224
|
+
const resultPre = h('pre', { className: 'sdt-ai-tool-pre' });
|
|
1225
|
+
resultPre.appendChild(h('code', null, toolCall.resultText));
|
|
1226
|
+
body.appendChild(resultPre);
|
|
1227
|
+
}
|
|
1228
|
+
if (toolCall.state === 'running') {
|
|
1229
|
+
body.appendChild(h('div', { className: 'sdt-ai-tool-running' }, 'Running...'));
|
|
1230
|
+
}
|
|
1231
|
+
toolCard.appendChild(body);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
return toolCard;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
function renderMessages() {
|
|
1238
|
+
messagesArea.innerHTML = '';
|
|
1239
|
+
|
|
1240
|
+
if (messages.length === 0) {
|
|
1241
|
+
const empty = h('div', { className: 'sdt-ai-empty' });
|
|
1242
|
+
const icon = h('div', { className: 'sdt-ai-empty-icon' });
|
|
1243
|
+
setHtml(icon, '<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>');
|
|
1244
|
+
empty.appendChild(icon);
|
|
1245
|
+
empty.appendChild(h('div', { className: 'sdt-ai-empty-title' }, 'Ask AI'));
|
|
1246
|
+
empty.appendChild(h('div', { className: 'sdt-ai-empty-desc' }, 'Get help with Hexclave integration, troubleshooting, and best practices.'));
|
|
1247
|
+
|
|
1248
|
+
const suggestions = h('div', { className: 'sdt-ai-suggestions' });
|
|
1249
|
+
for (const q of SUGGESTED_QUESTIONS) {
|
|
1250
|
+
const btn = h('button', { className: 'sdt-ai-suggestion' });
|
|
1251
|
+
btn.appendChild(h('span', { className: 'sdt-ai-suggestion-icon' }, q.icon));
|
|
1252
|
+
btn.appendChild(h('span', null, q.text));
|
|
1253
|
+
btn.addEventListener('click', () => {
|
|
1254
|
+
runAsynchronously(sendMessage(q.text));
|
|
1255
|
+
});
|
|
1256
|
+
suggestions.appendChild(btn);
|
|
1257
|
+
}
|
|
1258
|
+
empty.appendChild(suggestions);
|
|
1259
|
+
messagesArea.appendChild(empty);
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
const list = h('div', { className: 'sdt-ai-message-list' });
|
|
1264
|
+
for (const msg of messages) {
|
|
1265
|
+
if (msg.role === 'user') {
|
|
1266
|
+
const msgDiv = h('div', { className: 'sdt-ai-msg sdt-ai-msg-user' });
|
|
1267
|
+
const bubble = h('div', { className: 'sdt-ai-bubble sdt-ai-bubble-user' });
|
|
1268
|
+
bubble.appendChild(h('p', null, msg.content));
|
|
1269
|
+
msgDiv.appendChild(bubble);
|
|
1270
|
+
const avatarDiv = h('div', { className: 'sdt-ai-avatar sdt-ai-avatar-user' });
|
|
1271
|
+
setHtml(avatarDiv, '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>');
|
|
1272
|
+
msgDiv.appendChild(avatarDiv);
|
|
1273
|
+
list.appendChild(msgDiv);
|
|
1274
|
+
} else {
|
|
1275
|
+
const msgDiv = h('div', { className: 'sdt-ai-msg sdt-ai-msg-assistant' });
|
|
1276
|
+
const avatarDiv = h('div', { className: 'sdt-ai-avatar sdt-ai-avatar-assistant' });
|
|
1277
|
+
setHtml(avatarDiv, '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>');
|
|
1278
|
+
msgDiv.appendChild(avatarDiv);
|
|
1279
|
+
const bubble = h('div', { className: 'sdt-ai-bubble sdt-ai-bubble-assistant' });
|
|
1280
|
+
if (msg.parts.length === 0) {
|
|
1281
|
+
bubble.innerHTML = '<div class="sdt-ai-thinking"><span class="sdt-ai-thinking-dot"></span><span class="sdt-ai-thinking-dot"></span><span class="sdt-ai-thinking-dot"></span></div>';
|
|
1282
|
+
} else {
|
|
1283
|
+
for (const part of msg.parts) {
|
|
1284
|
+
if (part.type === 'text') {
|
|
1285
|
+
const textContainer = h('div', { className: 'sdt-ai-part-text' });
|
|
1286
|
+
renderMarkdownInto(textContainer, part.content);
|
|
1287
|
+
bubble.appendChild(textContainer);
|
|
1288
|
+
continue;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
const toolCall = msg.toolCallsById.get(part.toolCallId);
|
|
1292
|
+
if (toolCall == null) {
|
|
1293
|
+
const missingTool = h('div', { className: 'sdt-ai-tool-card' });
|
|
1294
|
+
const missingBody = h('div', { className: 'sdt-ai-tool-body' });
|
|
1295
|
+
missingBody.appendChild(h('div', { className: 'sdt-ai-tool-label' }, 'Error'));
|
|
1296
|
+
const missingPre = h('pre', { className: 'sdt-ai-tool-pre' });
|
|
1297
|
+
missingPre.appendChild(h('code', null, `Missing tool call state for ${part.toolCallId}`));
|
|
1298
|
+
missingBody.appendChild(missingPre);
|
|
1299
|
+
missingTool.appendChild(missingBody);
|
|
1300
|
+
bubble.appendChild(missingTool);
|
|
1301
|
+
continue;
|
|
1302
|
+
}
|
|
1303
|
+
const toolsContainer = h('div', { className: 'sdt-ai-tools' });
|
|
1304
|
+
toolsContainer.appendChild(renderToolCard(toolCall));
|
|
1305
|
+
bubble.appendChild(toolsContainer);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
msgDiv.appendChild(bubble);
|
|
1309
|
+
list.appendChild(msgDiv);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
messagesArea.appendChild(list);
|
|
1313
|
+
messagesArea.scrollTop = messagesArea.scrollHeight;
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
function renderMarkdownInto(el: HTMLElement, content: string) {
|
|
1317
|
+
function appendBlockWithInlineMarkdown(tag: "p" | "li" | "h1" | "h2" | "h3", className: string, text: string) {
|
|
1318
|
+
const block = h(tag, { className });
|
|
1319
|
+
appendInlineMarkdown(block, text);
|
|
1320
|
+
el.appendChild(block);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
const lines = content.split('\n');
|
|
1324
|
+
let i = 0;
|
|
1325
|
+
while (i < lines.length) {
|
|
1326
|
+
const line = lines[i];
|
|
1327
|
+
|
|
1328
|
+
if (line.startsWith('```')) {
|
|
1329
|
+
const lang = line.slice(3).trim();
|
|
1330
|
+
const codeLines: string[] = [];
|
|
1331
|
+
i++;
|
|
1332
|
+
while (i < lines.length && !lines[i].startsWith('```')) {
|
|
1333
|
+
codeLines.push(lines[i]);
|
|
1334
|
+
i++;
|
|
1335
|
+
}
|
|
1336
|
+
i++;
|
|
1337
|
+
const block = h('div', { className: 'sdt-ai-code-block' });
|
|
1338
|
+
const header = h('div', { className: 'sdt-ai-code-header' });
|
|
1339
|
+
header.appendChild(h('span', { className: 'sdt-ai-code-lang' }, lang || 'CODE'));
|
|
1340
|
+
const copyBtn = h('button', { className: 'sdt-ai-copy-btn' }, '\u2398');
|
|
1341
|
+
const code = codeLines.join('\n');
|
|
1342
|
+
copyBtn.addEventListener('click', () => {
|
|
1343
|
+
runAsynchronously(navigator.clipboard.writeText(code).then(() => {
|
|
1344
|
+
copyBtn.textContent = '\u2713';
|
|
1345
|
+
setTimeout(() => {
|
|
1346
|
+
copyBtn.textContent = '\u2398';
|
|
1347
|
+
}, 1500);
|
|
1348
|
+
}));
|
|
1349
|
+
});
|
|
1350
|
+
header.appendChild(copyBtn);
|
|
1351
|
+
block.appendChild(header);
|
|
1352
|
+
const pre = h('pre', { className: 'sdt-ai-code-pre' });
|
|
1353
|
+
pre.appendChild(h('code', null, code));
|
|
1354
|
+
block.appendChild(pre);
|
|
1355
|
+
el.appendChild(block);
|
|
1356
|
+
continue;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
const headingMatch = line.match(/^(#{1,3}) (.+)/);
|
|
1360
|
+
if (headingMatch) {
|
|
1361
|
+
const tag = `h${headingMatch[1].length}` as 'h1' | 'h2' | 'h3';
|
|
1362
|
+
appendBlockWithInlineMarkdown(tag, "sdt-ai-heading", headingMatch[2]);
|
|
1363
|
+
i++;
|
|
1364
|
+
continue;
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
if (/^[-*] /.test(line)) {
|
|
1368
|
+
const ul = h('ul', { className: 'sdt-ai-list' });
|
|
1369
|
+
while (i < lines.length && /^[-*] /.test(lines[i])) {
|
|
1370
|
+
const li = h("li");
|
|
1371
|
+
appendInlineMarkdown(li, lines[i].replace(/^[-*] /, ""));
|
|
1372
|
+
ul.appendChild(li);
|
|
1373
|
+
i++;
|
|
1374
|
+
}
|
|
1375
|
+
el.appendChild(ul);
|
|
1376
|
+
continue;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
if (/^\d+\. /.test(line)) {
|
|
1380
|
+
const ol = h('ol', { className: 'sdt-ai-list sdt-ai-list-ordered' });
|
|
1381
|
+
while (i < lines.length && /^\d+\. /.test(lines[i])) {
|
|
1382
|
+
const li = h("li");
|
|
1383
|
+
appendInlineMarkdown(li, lines[i].replace(/^\d+\. /, ""));
|
|
1384
|
+
ol.appendChild(li);
|
|
1385
|
+
i++;
|
|
1386
|
+
}
|
|
1387
|
+
el.appendChild(ol);
|
|
1388
|
+
continue;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
if (line.trim() === '') {
|
|
1392
|
+
i++;
|
|
1393
|
+
continue;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
appendBlockWithInlineMarkdown("p", "sdt-ai-paragraph", line);
|
|
1397
|
+
i++;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
function stringifyForDebug(value: unknown): string {
|
|
1402
|
+
if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
|
|
1403
|
+
return String(value);
|
|
1404
|
+
}
|
|
1405
|
+
return JSON.stringify(value, null, 2);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
function getLastItem<T>(items: readonly T[]): T | undefined {
|
|
1409
|
+
return items.length > 0 ? items[items.length - 1] : undefined;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
1413
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
function expectObject(value: unknown, payload: string): Record<string, unknown> {
|
|
1417
|
+
if (!isRecord(value)) {
|
|
1418
|
+
throw new Error(`SSE payload must be an object: ${payload}`);
|
|
1419
|
+
}
|
|
1420
|
+
return value;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
function getRequiredStringField(event: Record<string, unknown>, field: string, payload: string): string {
|
|
1424
|
+
const value = event[field];
|
|
1425
|
+
if (typeof value !== 'string') {
|
|
1426
|
+
throw new Error(`SSE event '${String(event.type)}' missing string '${field}': ${payload}`);
|
|
1427
|
+
}
|
|
1428
|
+
return value;
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
function getCurrentAssistantMessage(): AssistantMessage {
|
|
1432
|
+
const lastMessage = getLastItem(messages);
|
|
1433
|
+
if (lastMessage?.role !== 'assistant') {
|
|
1434
|
+
throw new Error('Expected current message to be an assistant message');
|
|
1435
|
+
}
|
|
1436
|
+
return lastMessage;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
function appendTextDelta(delta: string) {
|
|
1440
|
+
const assistantMessage = getCurrentAssistantMessage();
|
|
1441
|
+
const lastPart = getLastItem(assistantMessage.parts);
|
|
1442
|
+
if (lastPart?.type === 'text') {
|
|
1443
|
+
lastPart.content += delta;
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1446
|
+
assistantMessage.parts.push({ type: 'text', content: delta });
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
function ensureToolPart(assistantMessage: AssistantMessage, toolCallId: string) {
|
|
1450
|
+
const hasPart = assistantMessage.parts.some(part => part.type === 'tool' && part.toolCallId === toolCallId);
|
|
1451
|
+
if (!hasPart) {
|
|
1452
|
+
assistantMessage.parts.push({ type: 'tool', toolCallId });
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
function findOrCreateToolCall(toolCallId: string, fallbackToolName: string): ToolCall {
|
|
1457
|
+
const assistantMessage = getCurrentAssistantMessage();
|
|
1458
|
+
const existing = assistantMessage.toolCallsById.get(toolCallId);
|
|
1459
|
+
if (existing != null) {
|
|
1460
|
+
if (existing.toolName === 'tool' && fallbackToolName !== 'tool') {
|
|
1461
|
+
existing.toolName = fallbackToolName;
|
|
1462
|
+
}
|
|
1463
|
+
ensureToolPart(assistantMessage, toolCallId);
|
|
1464
|
+
return existing;
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
const created: ToolCall = {
|
|
1468
|
+
id: toolCallId,
|
|
1469
|
+
toolName: fallbackToolName,
|
|
1470
|
+
argsText: null,
|
|
1471
|
+
resultText: null,
|
|
1472
|
+
state: 'running',
|
|
1473
|
+
errorText: null,
|
|
1474
|
+
isExpanded: false,
|
|
1475
|
+
};
|
|
1476
|
+
assistantMessage.toolCallsById.set(toolCallId, created);
|
|
1477
|
+
ensureToolPart(assistantMessage, toolCallId);
|
|
1478
|
+
return created;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
async function sendMessage(text: string) {
|
|
1482
|
+
if (!text.trim() || aiLoading) return;
|
|
1483
|
+
messages.push({ role: 'user', content: text.trim() });
|
|
1484
|
+
messages.push({ role: 'assistant', parts: [], toolCallsById: new Map<string, ToolCall>() });
|
|
1485
|
+
aiLoading = true;
|
|
1486
|
+
renderMessages();
|
|
1487
|
+
renderInput();
|
|
1488
|
+
|
|
1489
|
+
try {
|
|
1490
|
+
const abortController = new AbortController();
|
|
1491
|
+
activeAiAbortController = abortController;
|
|
1492
|
+
const res = await fetch(`${apiBaseUrl}/api/latest/ai/query/stream`, {
|
|
1493
|
+
method: 'POST',
|
|
1494
|
+
headers: {
|
|
1495
|
+
'Content-Type': 'application/json',
|
|
1496
|
+
...getHeaders(),
|
|
1497
|
+
},
|
|
1498
|
+
signal: abortController.signal,
|
|
1499
|
+
body: JSON.stringify({
|
|
1500
|
+
systemPrompt: 'command-center-ask-ai',
|
|
1501
|
+
tools: ['docs'],
|
|
1502
|
+
quality: 'smart',
|
|
1503
|
+
speed: 'slow',
|
|
1504
|
+
messages: messages
|
|
1505
|
+
.slice(0, -1)
|
|
1506
|
+
.map((m) => ({
|
|
1507
|
+
role: m.role,
|
|
1508
|
+
content: [{ type: 'text', text: m.role === 'user' ? m.content : m.parts.filter(part => part.type === 'text').map(part => part.content).join('') }],
|
|
1509
|
+
})),
|
|
1510
|
+
}),
|
|
1511
|
+
});
|
|
1512
|
+
|
|
1513
|
+
if (!res.ok) {
|
|
1514
|
+
throw new Error(`AI request failed with status ${res.status}`);
|
|
1515
|
+
}
|
|
1516
|
+
if (!res.body) {
|
|
1517
|
+
throw new Error('AI request returned no response body');
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
const reader = res.body.getReader();
|
|
1521
|
+
const decoder = new TextDecoder();
|
|
1522
|
+
let buffer = '';
|
|
1523
|
+
|
|
1524
|
+
while (true) {
|
|
1525
|
+
const { done, value } = await reader.read();
|
|
1526
|
+
if (done) break;
|
|
1527
|
+
buffer += decoder.decode(value, { stream: true });
|
|
1528
|
+
const streamLines = buffer.split('\n');
|
|
1529
|
+
buffer = streamLines.pop() || '';
|
|
1530
|
+
|
|
1531
|
+
for (const streamLine of streamLines) {
|
|
1532
|
+
const line = streamLine.trim();
|
|
1533
|
+
if (line === '' || line.startsWith(':')) continue;
|
|
1534
|
+
if (!line.startsWith('data: ')) {
|
|
1535
|
+
throw new Error(`Unexpected SSE line: ${line}`);
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
const payload = line.slice(6);
|
|
1539
|
+
if (payload === '[DONE]') continue;
|
|
1540
|
+
const event = expectObject(JSON.parse(payload), payload);
|
|
1541
|
+
const eventType = getRequiredStringField(event, 'type', payload);
|
|
1542
|
+
|
|
1543
|
+
switch (eventType) {
|
|
1544
|
+
case 'start':
|
|
1545
|
+
case 'start-step':
|
|
1546
|
+
case 'finish-step':
|
|
1547
|
+
case 'finish':
|
|
1548
|
+
case 'message-metadata':
|
|
1549
|
+
case 'text-start':
|
|
1550
|
+
case 'text-end':
|
|
1551
|
+
case 'reasoning-start':
|
|
1552
|
+
case 'reasoning-delta':
|
|
1553
|
+
case 'reasoning-end':
|
|
1554
|
+
case 'source-url':
|
|
1555
|
+
case 'source-document':
|
|
1556
|
+
case 'file': {
|
|
1557
|
+
break;
|
|
1558
|
+
}
|
|
1559
|
+
case 'text-delta': {
|
|
1560
|
+
const delta = getRequiredStringField(event, 'delta', payload);
|
|
1561
|
+
appendTextDelta(delta);
|
|
1562
|
+
break;
|
|
1563
|
+
}
|
|
1564
|
+
case 'tool-input-start': {
|
|
1565
|
+
const toolCallId = getRequiredStringField(event, 'toolCallId', payload);
|
|
1566
|
+
const toolName = getRequiredStringField(event, 'toolName', payload);
|
|
1567
|
+
const toolCall = findOrCreateToolCall(toolCallId, toolName);
|
|
1568
|
+
toolCall.state = 'running';
|
|
1569
|
+
toolCall.resultText = null;
|
|
1570
|
+
toolCall.errorText = null;
|
|
1571
|
+
toolCall.argsText = '';
|
|
1572
|
+
break;
|
|
1573
|
+
}
|
|
1574
|
+
case 'tool-input-delta': {
|
|
1575
|
+
const toolCallId = getRequiredStringField(event, 'toolCallId', payload);
|
|
1576
|
+
const inputTextDelta = getRequiredStringField(event, 'inputTextDelta', payload);
|
|
1577
|
+
const toolCall = findOrCreateToolCall(toolCallId, 'tool');
|
|
1578
|
+
toolCall.argsText = (toolCall.argsText ?? '') + inputTextDelta;
|
|
1579
|
+
break;
|
|
1580
|
+
}
|
|
1581
|
+
case 'tool-input-available': {
|
|
1582
|
+
const toolCallId = getRequiredStringField(event, 'toolCallId', payload);
|
|
1583
|
+
const toolName = getRequiredStringField(event, 'toolName', payload);
|
|
1584
|
+
const toolCall = findOrCreateToolCall(toolCallId, toolName);
|
|
1585
|
+
toolCall.argsText = stringifyForDebug(event.input);
|
|
1586
|
+
break;
|
|
1587
|
+
}
|
|
1588
|
+
case 'tool-input-error': {
|
|
1589
|
+
const toolCallId = getRequiredStringField(event, 'toolCallId', payload);
|
|
1590
|
+
const toolName = getRequiredStringField(event, 'toolName', payload);
|
|
1591
|
+
const errorText = getRequiredStringField(event, 'errorText', payload);
|
|
1592
|
+
const toolCall = findOrCreateToolCall(toolCallId, toolName);
|
|
1593
|
+
toolCall.state = 'error';
|
|
1594
|
+
toolCall.errorText = errorText;
|
|
1595
|
+
toolCall.resultText = errorText;
|
|
1596
|
+
break;
|
|
1597
|
+
}
|
|
1598
|
+
case 'tool-output-available': {
|
|
1599
|
+
const toolCallId = getRequiredStringField(event, 'toolCallId', payload);
|
|
1600
|
+
const toolCall = findOrCreateToolCall(toolCallId, 'tool');
|
|
1601
|
+
const preliminary = event.preliminary === true;
|
|
1602
|
+
toolCall.resultText = stringifyForDebug(event.output);
|
|
1603
|
+
if (!preliminary) {
|
|
1604
|
+
toolCall.state = 'success';
|
|
1605
|
+
}
|
|
1606
|
+
break;
|
|
1607
|
+
}
|
|
1608
|
+
case 'tool-output-error': {
|
|
1609
|
+
const toolCallId = getRequiredStringField(event, 'toolCallId', payload);
|
|
1610
|
+
const errorText = getRequiredStringField(event, 'errorText', payload);
|
|
1611
|
+
const toolCall = findOrCreateToolCall(toolCallId, 'tool');
|
|
1612
|
+
toolCall.state = 'error';
|
|
1613
|
+
toolCall.errorText = errorText;
|
|
1614
|
+
toolCall.resultText = errorText;
|
|
1615
|
+
break;
|
|
1616
|
+
}
|
|
1617
|
+
case 'tool-output-denied': {
|
|
1618
|
+
const toolCallId = getRequiredStringField(event, 'toolCallId', payload);
|
|
1619
|
+
const toolCall = findOrCreateToolCall(toolCallId, 'tool');
|
|
1620
|
+
toolCall.state = 'error';
|
|
1621
|
+
toolCall.errorText = 'Tool output denied';
|
|
1622
|
+
toolCall.resultText = 'Tool output denied';
|
|
1623
|
+
break;
|
|
1624
|
+
}
|
|
1625
|
+
case 'tool-approval-request': {
|
|
1626
|
+
const toolCallId = getRequiredStringField(event, 'toolCallId', payload);
|
|
1627
|
+
const approvalId = getRequiredStringField(event, 'approvalId', payload);
|
|
1628
|
+
const toolCall = findOrCreateToolCall(toolCallId, 'tool');
|
|
1629
|
+
toolCall.state = 'running';
|
|
1630
|
+
toolCall.resultText = `Approval requested (${approvalId})`;
|
|
1631
|
+
break;
|
|
1632
|
+
}
|
|
1633
|
+
case 'abort': {
|
|
1634
|
+
const reason = typeof event.reason === 'string' ? event.reason : 'unknown reason';
|
|
1635
|
+
throw new Error(`AI stream aborted: ${reason}`);
|
|
1636
|
+
}
|
|
1637
|
+
case 'error': {
|
|
1638
|
+
throw new Error(
|
|
1639
|
+
typeof event.errorText === 'string'
|
|
1640
|
+
? `AI stream error: ${event.errorText}`
|
|
1641
|
+
: `AI stream error event: ${payload}`
|
|
1642
|
+
);
|
|
1643
|
+
}
|
|
1644
|
+
default: {
|
|
1645
|
+
if (eventType.startsWith('data-')) {
|
|
1646
|
+
break;
|
|
1647
|
+
}
|
|
1648
|
+
throw new Error(`Unexpected AI stream event type: ${eventType}`);
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
renderMessages();
|
|
1654
|
+
}
|
|
1655
|
+
} catch (error) {
|
|
1656
|
+
if (error instanceof DOMException && error.name === 'AbortError') {
|
|
1657
|
+
const assistantMessage = getCurrentAssistantMessage();
|
|
1658
|
+
if (assistantMessage.parts.length === 0) {
|
|
1659
|
+
assistantMessage.parts.push({ type: 'text', content: 'Stopped.' });
|
|
1660
|
+
}
|
|
1661
|
+
renderMessages();
|
|
1662
|
+
return;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
const message = error instanceof Error ? error.message : 'Unknown AI stream error';
|
|
1666
|
+
const lastMessage = getLastItem(messages);
|
|
1667
|
+
if (lastMessage?.role === 'assistant') {
|
|
1668
|
+
lastMessage.parts = [{ type: 'text', content: message }];
|
|
1669
|
+
lastMessage.toolCallsById.clear();
|
|
1670
|
+
}
|
|
1671
|
+
renderMessages();
|
|
1672
|
+
alert(`AI stream failed: ${message}`);
|
|
1673
|
+
} finally {
|
|
1674
|
+
aiLoading = false;
|
|
1675
|
+
activeAiAbortController = null;
|
|
1676
|
+
renderMessages();
|
|
1677
|
+
renderInput();
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
const inputWrapper = h('div', { className: 'sdt-ai-input-wrapper' });
|
|
1682
|
+
const input = h('input', {
|
|
1683
|
+
type: 'text',
|
|
1684
|
+
className: 'sdt-ai-input',
|
|
1685
|
+
placeholder: 'Ask anything about Hexclave...',
|
|
1686
|
+
autocomplete: 'off',
|
|
1687
|
+
autocorrect: 'off',
|
|
1688
|
+
spellcheck: 'false',
|
|
1689
|
+
}) as HTMLInputElement;
|
|
1690
|
+
const sendBtn = h('button', { className: 'sdt-ai-send-btn', title: 'Send' });
|
|
1691
|
+
setHtml(sendBtn, '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg>');
|
|
1692
|
+
|
|
1693
|
+
function renderInput() {
|
|
1694
|
+
input.disabled = false;
|
|
1695
|
+
input.placeholder = messages.length === 0 ? 'Ask anything about Hexclave...' : 'Ask a follow-up...';
|
|
1696
|
+
if (aiLoading) {
|
|
1697
|
+
sendBtn.classList.add('sdt-ai-send-btn-active');
|
|
1698
|
+
sendBtn.classList.add('sdt-ai-stop-btn');
|
|
1699
|
+
sendBtn.setAttribute('title', 'Stop');
|
|
1700
|
+
setHtml(sendBtn, '<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>');
|
|
1701
|
+
} else if (input.value.trim()) {
|
|
1702
|
+
sendBtn.classList.add('sdt-ai-send-btn-active');
|
|
1703
|
+
sendBtn.classList.remove('sdt-ai-stop-btn');
|
|
1704
|
+
sendBtn.setAttribute('title', 'Send');
|
|
1705
|
+
setHtml(sendBtn, '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg>');
|
|
1706
|
+
} else {
|
|
1707
|
+
sendBtn.classList.remove('sdt-ai-send-btn-active');
|
|
1708
|
+
sendBtn.classList.remove('sdt-ai-stop-btn');
|
|
1709
|
+
sendBtn.setAttribute('title', 'Send');
|
|
1710
|
+
setHtml(sendBtn, '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg>');
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
input.addEventListener('input', renderInput);
|
|
1715
|
+
input.addEventListener('keydown', (e) => {
|
|
1716
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
1717
|
+
e.preventDefault();
|
|
1718
|
+
if (aiLoading) {
|
|
1719
|
+
activeAiAbortController?.abort();
|
|
1720
|
+
} else {
|
|
1721
|
+
runAsynchronously(sendMessage(input.value));
|
|
1722
|
+
input.value = '';
|
|
1723
|
+
}
|
|
1724
|
+
renderInput();
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
sendBtn.addEventListener('click', () => {
|
|
1728
|
+
if (aiLoading) {
|
|
1729
|
+
activeAiAbortController?.abort();
|
|
1730
|
+
} else {
|
|
1731
|
+
runAsynchronously(sendMessage(input.value));
|
|
1732
|
+
input.value = '';
|
|
1733
|
+
}
|
|
1734
|
+
renderInput();
|
|
1735
|
+
});
|
|
1736
|
+
|
|
1737
|
+
const newChatBtn = h('button', { className: 'sdt-ai-new-chat', title: 'New conversation', style: { display: 'none' } });
|
|
1738
|
+
setHtml(newChatBtn, '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>');
|
|
1739
|
+
newChatBtn.addEventListener('click', () => {
|
|
1740
|
+
if (aiLoading) {
|
|
1741
|
+
activeAiAbortController?.abort();
|
|
1742
|
+
}
|
|
1743
|
+
messages.length = 0;
|
|
1744
|
+
input.value = '';
|
|
1745
|
+
renderMessages();
|
|
1746
|
+
renderInput();
|
|
1747
|
+
newChatBtn.style.display = 'none';
|
|
1748
|
+
});
|
|
1749
|
+
|
|
1750
|
+
inputWrapper.append(input, sendBtn);
|
|
1751
|
+
inputArea.append(newChatBtn, inputWrapper);
|
|
1752
|
+
|
|
1753
|
+
container.append(messagesArea, inputArea);
|
|
1754
|
+
renderMessages();
|
|
1755
|
+
renderInput();
|
|
1756
|
+
|
|
1757
|
+
return container;
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
// ---------------------------------------------------------------------------
|
|
1761
|
+
// Dashboard tab
|
|
1762
|
+
// ---------------------------------------------------------------------------
|
|
1763
|
+
|
|
1764
|
+
function createDashboardTab(app: StackClientApp<true>): HTMLElement {
|
|
1765
|
+
const dashboardUrl = resolveDashboardUrl(app);
|
|
1766
|
+
return createIframeTab(dashboardUrl, 'Hexclave Dashboard', 'Loading dashboard\u2026', 'Unable to load dashboard', 'The dashboard may require authentication or block framing', 'Open in New Tab');
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
// ---------------------------------------------------------------------------
|
|
1770
|
+
// Support tab
|
|
1771
|
+
// ---------------------------------------------------------------------------
|
|
1772
|
+
|
|
1773
|
+
function createSupportTab(app: StackClientApp<true>): HTMLElement {
|
|
1774
|
+
const container = h('div', { className: 'sdt-support-tab' });
|
|
1775
|
+
const apiBaseUrl = resolveApiBaseUrl(app);
|
|
1776
|
+
|
|
1777
|
+
function createFeedbackForm(): HTMLElement {
|
|
1778
|
+
const pane = h('div', { className: 'sdt-support-feedback-pane' });
|
|
1779
|
+
const form = h('form', { className: 'sdt-support-form' });
|
|
1780
|
+
|
|
1781
|
+
let feedbackType: 'feedback' | 'bug' = 'feedback';
|
|
1782
|
+
let status: 'idle' | 'submitting' | 'success' | 'error' = 'idle';
|
|
1783
|
+
let errorMessage = '';
|
|
1784
|
+
|
|
1785
|
+
const nameInput = h('input', { className: 'sdt-support-input', type: 'text', placeholder: 'Your name' }) as HTMLInputElement;
|
|
1786
|
+
const emailInput = h('input', { className: 'sdt-support-input', type: 'email', placeholder: 'you@example.com', required: 'true' }) as HTMLInputElement;
|
|
1787
|
+
const messageInput = h('textarea', { className: 'sdt-support-textarea', placeholder: "What's on your mind?", required: 'true', rows: '5' }) as HTMLTextAreaElement;
|
|
1788
|
+
|
|
1789
|
+
function render() {
|
|
1790
|
+
form.innerHTML = '';
|
|
1791
|
+
|
|
1792
|
+
if (status === 'success') {
|
|
1793
|
+
const successDiv = h('div', { className: 'sdt-support-status sdt-support-status-success' });
|
|
1794
|
+
const icon = h('div', { className: 'sdt-support-status-icon' });
|
|
1795
|
+
setHtml(icon, '<svg width="20" height="20" viewBox="0 0 20 20" fill="none"><path d="M6 10l3 3 5-6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>');
|
|
1796
|
+
successDiv.append(
|
|
1797
|
+
icon,
|
|
1798
|
+
h('div', { className: 'sdt-support-status-title' }, 'Feedback sent'),
|
|
1799
|
+
h('div', { className: 'sdt-support-status-msg' }, "Thank you! We'll get back to you soon."),
|
|
1800
|
+
);
|
|
1801
|
+
const resetBtn = h('button', { className: 'sdt-support-submit', style: { marginTop: '12px', width: 'auto' } }, 'Send another');
|
|
1802
|
+
resetBtn.addEventListener('click', () => {
|
|
1803
|
+
status = 'idle';
|
|
1804
|
+
render();
|
|
1805
|
+
});
|
|
1806
|
+
successDiv.appendChild(resetBtn);
|
|
1807
|
+
form.appendChild(successDiv);
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
if (status === 'error') {
|
|
1812
|
+
const errDiv = h('div', { className: 'sdt-support-status sdt-support-status-error' });
|
|
1813
|
+
const icon = h('div', { className: 'sdt-support-status-icon' });
|
|
1814
|
+
setHtml(icon, '<svg width="20" height="20" viewBox="0 0 20 20" fill="none"><path d="M10 6v5m0 3h.01" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>');
|
|
1815
|
+
errDiv.append(
|
|
1816
|
+
icon,
|
|
1817
|
+
h('div', { className: 'sdt-support-status-title' }, 'Failed to send'),
|
|
1818
|
+
h('div', { className: 'sdt-support-status-msg' }, errorMessage || 'Please try again.'),
|
|
1819
|
+
);
|
|
1820
|
+
const retryBtn = h('button', { className: 'sdt-support-submit', style: { marginTop: '12px', width: 'auto' } }, 'Try again');
|
|
1821
|
+
retryBtn.addEventListener('click', () => {
|
|
1822
|
+
status = 'idle';
|
|
1823
|
+
errorMessage = '';
|
|
1824
|
+
render();
|
|
1825
|
+
});
|
|
1826
|
+
errDiv.appendChild(retryBtn);
|
|
1827
|
+
form.appendChild(errDiv);
|
|
1828
|
+
return;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
const nameField = h('div', { className: 'sdt-support-field' });
|
|
1832
|
+
const nameLabel = h('label', { className: 'sdt-support-label' }, 'Name ');
|
|
1833
|
+
nameLabel.appendChild(h('span', { className: 'sdt-support-optional' }, 'optional'));
|
|
1834
|
+
nameField.append(nameLabel, nameInput);
|
|
1835
|
+
form.appendChild(nameField);
|
|
1836
|
+
|
|
1837
|
+
const emailField = h('div', { className: 'sdt-support-field' });
|
|
1838
|
+
emailField.append(h('label', { className: 'sdt-support-label' }, 'Email'), emailInput);
|
|
1839
|
+
form.appendChild(emailField);
|
|
1840
|
+
|
|
1841
|
+
const msgField = h('div', { className: 'sdt-support-field' });
|
|
1842
|
+
msgField.append(h('label', { className: 'sdt-support-label' }, feedbackType === 'bug' ? 'Description' : 'Message'), messageInput);
|
|
1843
|
+
messageInput.placeholder = feedbackType === 'bug' ? 'Steps to reproduce, expected vs. actual behavior\u2026' : "What's on your mind?";
|
|
1844
|
+
form.appendChild(msgField);
|
|
1845
|
+
|
|
1846
|
+
const typeCards = h('div', { className: 'sdt-support-type-cards' });
|
|
1847
|
+
const feedbackBtn = h('button', { type: 'button', className: `sdt-support-type-card ${feedbackType === 'feedback' ? 'sdt-support-type-card-active' : ''}` });
|
|
1848
|
+
setHtml(feedbackBtn, '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg><span>Feedback</span>');
|
|
1849
|
+
feedbackBtn.addEventListener('click', () => {
|
|
1850
|
+
feedbackType = 'feedback';
|
|
1851
|
+
render();
|
|
1852
|
+
});
|
|
1853
|
+
const bugBtn = h('button', { type: 'button', className: `sdt-support-type-card ${feedbackType === 'bug' ? 'sdt-support-type-card-active' : ''}` });
|
|
1854
|
+
setHtml(bugBtn, '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2l1.88 1.88M14.12 3.88L16 2M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9M6.53 9C4.6 8.8 3 7.1 3 5M6 13H2M6 17H3M21 5c0 2.1-1.6 3.8-3.53 4M18 13h4M21 17h-3"/></svg><span>Bug Report</span>');
|
|
1855
|
+
bugBtn.addEventListener('click', () => {
|
|
1856
|
+
feedbackType = 'bug';
|
|
1857
|
+
render();
|
|
1858
|
+
});
|
|
1859
|
+
typeCards.append(feedbackBtn, bugBtn);
|
|
1860
|
+
form.appendChild(typeCards);
|
|
1861
|
+
|
|
1862
|
+
const submitBtn = h('button', { type: 'submit', className: 'sdt-support-submit' });
|
|
1863
|
+
setHtml(submitBtn, 'Submit <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg>');
|
|
1864
|
+
submitBtn.disabled = status === 'submitting';
|
|
1865
|
+
form.appendChild(submitBtn);
|
|
1866
|
+
|
|
1867
|
+
const channels = h('div', { className: 'sdt-support-channels' });
|
|
1868
|
+
channels.innerHTML = `
|
|
1869
|
+
<a href="https://discord.hexclave.com" target="_blank" rel="noopener noreferrer" class="sdt-support-channel">
|
|
1870
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"/></svg>
|
|
1871
|
+
<span>Discord</span>
|
|
1872
|
+
</a>
|
|
1873
|
+
<a href="mailto:team@hexclave.com" class="sdt-support-channel">
|
|
1874
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="20" height="16" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/></svg>
|
|
1875
|
+
<span>Email</span>
|
|
1876
|
+
</a>
|
|
1877
|
+
<a href="https://github.com/hexclave/hexclave" target="_blank" rel="noopener noreferrer" class="sdt-support-channel">
|
|
1878
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.374 0 0 5.373 0 12c0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23A11.509 11.509 0 0 1 12 5.803c1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576C20.566 21.797 24 17.3 24 12c0-6.627-5.373-12-12-12z"/></svg>
|
|
1879
|
+
<span>GitHub</span>
|
|
1880
|
+
</a>`;
|
|
1881
|
+
form.appendChild(channels);
|
|
1882
|
+
form.insertBefore(channels, form.firstChild);
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
form.addEventListener('submit', (e) => {
|
|
1886
|
+
e.preventDefault();
|
|
1887
|
+
if (!emailInput.value.trim() || !messageInput.value.trim()) return;
|
|
1888
|
+
runAsynchronously(async () => {
|
|
1889
|
+
status = 'submitting';
|
|
1890
|
+
render();
|
|
1891
|
+
try {
|
|
1892
|
+
const response = await fetch(`${apiBaseUrl}/api/latest/internal/feedback`, {
|
|
1893
|
+
method: 'POST',
|
|
1894
|
+
headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
|
|
1895
|
+
body: JSON.stringify({
|
|
1896
|
+
name: nameInput.value.trim() || undefined,
|
|
1897
|
+
email: emailInput.value.trim(),
|
|
1898
|
+
message: messageInput.value.trim(),
|
|
1899
|
+
feedback_type: feedbackType,
|
|
1900
|
+
}),
|
|
1901
|
+
});
|
|
1902
|
+
if (!response.ok) {
|
|
1903
|
+
throw new Error(`Failed to send: ${response.status} ${response.statusText}`);
|
|
1904
|
+
}
|
|
1905
|
+
const result = await response.json();
|
|
1906
|
+
if (!result.success) {
|
|
1907
|
+
throw new Error(result.message || 'Failed to send feedback');
|
|
1908
|
+
}
|
|
1909
|
+
status = 'success';
|
|
1910
|
+
messageInput.value = '';
|
|
1911
|
+
} catch (err: any) {
|
|
1912
|
+
status = 'error';
|
|
1913
|
+
errorMessage = err.message || 'An unexpected error occurred';
|
|
1914
|
+
}
|
|
1915
|
+
render();
|
|
1916
|
+
});
|
|
1917
|
+
});
|
|
1918
|
+
|
|
1919
|
+
render();
|
|
1920
|
+
pane.appendChild(form);
|
|
1921
|
+
return pane;
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
container.appendChild(createFeedbackForm());
|
|
1925
|
+
return container;
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
// ---------------------------------------------------------------------------
|
|
1929
|
+
// Components tab
|
|
1930
|
+
// ---------------------------------------------------------------------------
|
|
1931
|
+
|
|
1932
|
+
function createComponentsTab(app: StackClientApp<true>): HTMLElement {
|
|
1933
|
+
const container = h('div', { className: 'sdt-pg-layout' });
|
|
1934
|
+
const apiBaseUrl = resolveApiBaseUrl(app);
|
|
1935
|
+
const urls = app.urls;
|
|
1936
|
+
const urlOptions: HandlerUrlOptions = app[hexclaveAppInternalsSymbol].getConstructorOptions().urls ?? {};
|
|
1937
|
+
|
|
1938
|
+
const PAGE_ENTRIES: { key: keyof HandlerUrls; label: string }[] = [
|
|
1939
|
+
{ key: 'signIn' as any, label: 'Sign-in' },
|
|
1940
|
+
{ key: 'signUp' as any, label: 'Sign-up' },
|
|
1941
|
+
{ key: 'forgotPassword' as any, label: 'Forgot password' },
|
|
1942
|
+
{ key: 'passwordReset' as any, label: 'Password reset' },
|
|
1943
|
+
{ key: 'emailVerification' as any, label: 'Email verification' },
|
|
1944
|
+
{ key: 'accountSettings' as any, label: 'Account settings' },
|
|
1945
|
+
{ key: 'teamInvitation' as any, label: 'Team invitation' },
|
|
1946
|
+
{ key: 'cliAuthConfirm' as any, label: 'CLI auth confirmation' },
|
|
1947
|
+
{ key: 'mfa' as any, label: 'MFA' },
|
|
1948
|
+
{ key: 'onboarding' as any, label: 'Onboarding' },
|
|
1949
|
+
{ key: 'error' as any, label: 'Error' },
|
|
1950
|
+
];
|
|
1951
|
+
|
|
1952
|
+
type PageClassification = 'handler-component' | 'hosted' | 'custom';
|
|
1953
|
+
|
|
1954
|
+
function classifyPage(key: keyof HandlerUrls): { classification: PageClassification; version: number | null } {
|
|
1955
|
+
const target: HandlerUrlTarget = (urlOptions as any)[key] ?? (urlOptions as any).default ?? { type: 'handler-component' };
|
|
1956
|
+
if (typeof target === 'string') {
|
|
1957
|
+
return { classification: 'custom', version: null };
|
|
1958
|
+
}
|
|
1959
|
+
if ('type' in target) {
|
|
1960
|
+
if (target.type === 'custom') {
|
|
1961
|
+
return { classification: 'custom', version: (target as any).version ?? null };
|
|
1962
|
+
}
|
|
1963
|
+
return { classification: target.type as PageClassification, version: null };
|
|
1964
|
+
}
|
|
1965
|
+
return { classification: 'handler-component', version: null };
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
type PageInfo = {
|
|
1969
|
+
key: keyof HandlerUrls;
|
|
1970
|
+
label: string;
|
|
1971
|
+
url: string;
|
|
1972
|
+
classification: PageClassification;
|
|
1973
|
+
version: number | null;
|
|
1974
|
+
versionStatus: string;
|
|
1975
|
+
versionChangelogs: { version: number; changelog: string }[];
|
|
1976
|
+
};
|
|
1977
|
+
|
|
1978
|
+
let latestVersions: Map<string, { version: number; changelogs: Record<number, string> }> | null = null;
|
|
1979
|
+
let selectedKey: string | null = null;
|
|
1980
|
+
|
|
1981
|
+
runAsynchronously(
|
|
1982
|
+
fetch(`${apiBaseUrl}/api/latest/internal/component-versions`)
|
|
1983
|
+
.then((r) => r.json())
|
|
1984
|
+
.then((data) => {
|
|
1985
|
+
latestVersions = new Map(Object.entries(data.versions ?? {}));
|
|
1986
|
+
renderSidebar();
|
|
1987
|
+
})
|
|
1988
|
+
.catch(() => {})
|
|
1989
|
+
);
|
|
1990
|
+
|
|
1991
|
+
function buildPages(): PageInfo[] {
|
|
1992
|
+
return PAGE_ENTRIES.map((entry) => {
|
|
1993
|
+
const { classification, version } = classifyPage(entry.key);
|
|
1994
|
+
let versionStatus = 'current';
|
|
1995
|
+
let versionChangelogs: { version: number; changelog: string }[] = [];
|
|
1996
|
+
|
|
1997
|
+
if (classification === 'custom' && version != null && latestVersions) {
|
|
1998
|
+
const info = latestVersions.get(entry.key as string);
|
|
1999
|
+
if (info && version < info.version) {
|
|
2000
|
+
versionStatus = 'outdated';
|
|
2001
|
+
versionChangelogs = Object.entries(info.changelogs)
|
|
2002
|
+
.map(([v, cl]) => ({ version: Number(v), changelog: cl }))
|
|
2003
|
+
.filter((e) => e.version > version)
|
|
2004
|
+
.sort((a, b) => a.version - b.version);
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
return {
|
|
2009
|
+
key: entry.key,
|
|
2010
|
+
label: entry.label,
|
|
2011
|
+
url: (urls as any)[entry.key] || '',
|
|
2012
|
+
classification,
|
|
2013
|
+
version,
|
|
2014
|
+
versionStatus,
|
|
2015
|
+
versionChangelogs,
|
|
2016
|
+
};
|
|
2017
|
+
});
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
function getCompactUrl(url: string): string {
|
|
2021
|
+
const resolved = new URL(url, window.location.origin);
|
|
2022
|
+
return `${resolved.pathname}${resolved.search}${resolved.hash}`;
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
const sidebar = h('div', { className: 'sdt-pg-sidebar' });
|
|
2026
|
+
const mainArea = h('div', { className: 'sdt-pg-main' });
|
|
2027
|
+
|
|
2028
|
+
function renderSidebar() {
|
|
2029
|
+
sidebar.innerHTML = '';
|
|
2030
|
+
const pages = buildPages();
|
|
2031
|
+
const outdatedCount = pages.filter((p) => p.versionStatus === 'outdated').length;
|
|
2032
|
+
|
|
2033
|
+
const head = h('div', { className: 'sdt-pg-sidebar-head' });
|
|
2034
|
+
head.appendChild(h('span', { className: 'sdt-pg-sidebar-title' }, 'Pages'));
|
|
2035
|
+
head.appendChild(h('span', { className: 'sdt-pg-sidebar-count' }, String(pages.length)));
|
|
2036
|
+
if (outdatedCount > 0) {
|
|
2037
|
+
head.appendChild(h('span', { className: 'sdt-pg-sidebar-warn' }, `${outdatedCount} outdated`));
|
|
2038
|
+
}
|
|
2039
|
+
sidebar.appendChild(head);
|
|
2040
|
+
|
|
2041
|
+
const list = h('div', { className: 'sdt-pg-list' });
|
|
2042
|
+
for (const page of pages) {
|
|
2043
|
+
const isOutdated = page.versionStatus === 'outdated';
|
|
2044
|
+
const item = h('div', {
|
|
2045
|
+
className: `sdt-pg-item ${isOutdated ? 'sdt-pg-item-warn' : ''}`,
|
|
2046
|
+
'data-selected': String(selectedKey === page.key),
|
|
2047
|
+
});
|
|
2048
|
+
const dotClass = isOutdated
|
|
2049
|
+
? 'sdt-pg-item-dot-warn'
|
|
2050
|
+
: page.classification === 'custom'
|
|
2051
|
+
? 'sdt-pg-item-dot-custom'
|
|
2052
|
+
: 'sdt-pg-item-dot-handler';
|
|
2053
|
+
item.appendChild(h('span', { className: `sdt-pg-item-dot ${dotClass}` }));
|
|
2054
|
+
item.appendChild(h('span', { className: 'sdt-pg-item-label' }, page.label));
|
|
2055
|
+
if (isOutdated) {
|
|
2056
|
+
item.appendChild(h('span', { className: 'sdt-pg-badge sdt-pg-badge-outdated' }, 'Outdated'));
|
|
2057
|
+
}
|
|
2058
|
+
item.addEventListener('click', () => {
|
|
2059
|
+
selectedKey = page.key as string;
|
|
2060
|
+
renderSidebar();
|
|
2061
|
+
renderDetail(page);
|
|
2062
|
+
});
|
|
2063
|
+
list.appendChild(item);
|
|
2064
|
+
}
|
|
2065
|
+
sidebar.appendChild(list);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
function renderDetail(page: PageInfo) {
|
|
2069
|
+
mainArea.innerHTML = '';
|
|
2070
|
+
const detail = h('div', { className: 'sdt-pg-detail' });
|
|
2071
|
+
|
|
2072
|
+
const header = h('div', { className: 'sdt-pg-header' });
|
|
2073
|
+
const headerTop = h('div', { className: 'sdt-pg-header-top' });
|
|
2074
|
+
headerTop.appendChild(h('h3', { className: 'sdt-pg-title' }, `${page.label} Page`));
|
|
2075
|
+
headerTop.appendChild(h('a', { href: page.url, target: '_blank', rel: 'noopener noreferrer', className: 'sdt-pg-title-url' }, getCompactUrl(page.url)));
|
|
2076
|
+
if (page.versionStatus === 'outdated') {
|
|
2077
|
+
headerTop.appendChild(h('span', { className: 'sdt-pg-badge sdt-pg-badge-outdated' }, 'Outdated'));
|
|
2078
|
+
}
|
|
2079
|
+
header.appendChild(headerTop);
|
|
2080
|
+
|
|
2081
|
+
const redirectMethod = `hexclaveApp.redirectTo${(page.key as string).charAt(0).toUpperCase()}${(page.key as string).slice(1)}()`;
|
|
2082
|
+
const codeRow = h('div', { className: 'sdt-pg-code-inline' });
|
|
2083
|
+
codeRow.appendChild(h('code', { className: 'sdt-pg-code' }, redirectMethod));
|
|
2084
|
+
const openBtn = h('button', { className: 'sdt-pg-copy-btn sdt-pg-open-btn' });
|
|
2085
|
+
setHtml(openBtn, 'Open <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 17L17 7"/><path d="M7 7h10v10"/></svg>');
|
|
2086
|
+
openBtn.addEventListener('click', () => {
|
|
2087
|
+
const resolved = new URL(page.url, window.location.origin);
|
|
2088
|
+
window.open(resolved.toString(), '_blank', 'noopener,noreferrer');
|
|
2089
|
+
});
|
|
2090
|
+
codeRow.appendChild(openBtn);
|
|
2091
|
+
header.appendChild(codeRow);
|
|
2092
|
+
detail.appendChild(header);
|
|
2093
|
+
|
|
2094
|
+
const prompt = getPagePrompt(page.key as string, page.version ?? undefined);
|
|
2095
|
+
if (prompt) {
|
|
2096
|
+
const isOutdated = page.versionStatus === 'outdated';
|
|
2097
|
+
const showPrompt = page.classification === 'handler-component' || page.classification === 'hosted' || isOutdated;
|
|
2098
|
+
if (showPrompt) {
|
|
2099
|
+
let promptText: string;
|
|
2100
|
+
if (isOutdated && prompt.upgradePrompt) {
|
|
2101
|
+
promptText = prompt.upgradePrompt;
|
|
2102
|
+
} else if (prompt.fullPrompt) {
|
|
2103
|
+
promptText = prompt.fullPrompt;
|
|
2104
|
+
} else {
|
|
2105
|
+
promptText = '';
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
if (promptText) {
|
|
2109
|
+
const section = h('div', { className: 'sdt-pg-section' });
|
|
2110
|
+
section.appendChild(h('div', { className: 'sdt-pg-section-label' }, isOutdated ? 'Use this prompt to upgrade your component:' : 'Want to customize this page? Paste this prompt into your coding agent.'));
|
|
2111
|
+
section.appendChild(h('pre', { className: 'sdt-pg-pre' }, promptText));
|
|
2112
|
+
const footer = h('div', { className: 'sdt-pg-section-footer' });
|
|
2113
|
+
const copyBtn = h('button', { className: 'sdt-pg-copy-btn' }, 'Copy prompt');
|
|
2114
|
+
copyBtn.addEventListener('click', () => {
|
|
2115
|
+
runAsynchronously(navigator.clipboard.writeText(promptText).then(() => {
|
|
2116
|
+
copyBtn.textContent = '\u2713 Copied';
|
|
2117
|
+
setTimeout(() => {
|
|
2118
|
+
copyBtn.textContent = 'Copy prompt';
|
|
2119
|
+
}, 1500);
|
|
2120
|
+
}));
|
|
2121
|
+
});
|
|
2122
|
+
footer.appendChild(copyBtn);
|
|
2123
|
+
section.appendChild(footer);
|
|
2124
|
+
detail.appendChild(section);
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
mainArea.appendChild(detail);
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
function renderEmptyMain() {
|
|
2133
|
+
mainArea.innerHTML = '';
|
|
2134
|
+
const empty = h('div', { className: 'sdt-pg-empty' });
|
|
2135
|
+
const icon = h('div', { className: 'sdt-pg-empty-icon' });
|
|
2136
|
+
setHtml(icon, '<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg>');
|
|
2137
|
+
empty.appendChild(icon);
|
|
2138
|
+
empty.appendChild(h('div', { className: 'sdt-pg-empty-text' }, 'Select a page to inspect'));
|
|
2139
|
+
empty.appendChild(h('div', { className: 'sdt-pg-empty-sub' }, 'View configuration, preview, and upgrade prompts'));
|
|
2140
|
+
mainArea.appendChild(empty);
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
renderSidebar();
|
|
2144
|
+
renderEmptyMain();
|
|
2145
|
+
|
|
2146
|
+
container.append(sidebar, mainArea);
|
|
2147
|
+
return container;
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
// ---------------------------------------------------------------------------
|
|
2151
|
+
// Panel (main shell with tab bar and content area)
|
|
2152
|
+
// ---------------------------------------------------------------------------
|
|
2153
|
+
|
|
2154
|
+
function createPanel(
|
|
2155
|
+
app: StackClientApp<true>,
|
|
2156
|
+
state: ReturnType<typeof createStateStore>,
|
|
2157
|
+
logStore: LogStore,
|
|
2158
|
+
onClose: () => void,
|
|
2159
|
+
): { element: HTMLElement, cleanup: () => void } {
|
|
2160
|
+
const panel = h('div', { className: 'sdt-panel' });
|
|
2161
|
+
let panelAnimationTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
2162
|
+
|
|
2163
|
+
function animateNextPanelGeometryChange() {
|
|
2164
|
+
panel.classList.add('sdt-panel-geometry-animated');
|
|
2165
|
+
if (panelAnimationTimeout !== null) {
|
|
2166
|
+
clearTimeout(panelAnimationTimeout);
|
|
2167
|
+
}
|
|
2168
|
+
panelAnimationTimeout = setTimeout(() => {
|
|
2169
|
+
panel.classList.remove('sdt-panel-geometry-animated');
|
|
2170
|
+
panelAnimationTimeout = null;
|
|
2171
|
+
}, 220);
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
function applyPanelMode(tabId: TabId, opts?: { animate?: boolean }) {
|
|
2175
|
+
if (opts?.animate === true) {
|
|
2176
|
+
animateNextPanelGeometryChange();
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
if (tabId === 'dashboard') {
|
|
2180
|
+
panel.classList.add('sdt-panel-fullscreen');
|
|
2181
|
+
panel.style.width = '';
|
|
2182
|
+
panel.style.height = '';
|
|
2183
|
+
return;
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
panel.classList.remove('sdt-panel-fullscreen');
|
|
2187
|
+
panel.style.width = state.get().panelWidth + 'px';
|
|
2188
|
+
panel.style.height = state.get().panelHeight + 'px';
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
const tabs = getTabsForApp(app);
|
|
2192
|
+
const storedActiveTab = state.get().activeTab;
|
|
2193
|
+
const activeTab = tabs.some((tab) => tab.id === storedActiveTab) ? storedActiveTab : DEFAULT_STATE.activeTab;
|
|
2194
|
+
|
|
2195
|
+
applyPanelMode(activeTab);
|
|
2196
|
+
|
|
2197
|
+
const inner = h('div', { className: 'sdt-panel-inner' });
|
|
2198
|
+
|
|
2199
|
+
const closeBtn = h('button', { className: 'sdt-close-btn', 'aria-label': 'Close' });
|
|
2200
|
+
setHtml(closeBtn, '<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="3" y1="3" x2="11" y2="11"/><line x1="11" y1="3" x2="3" y2="11"/></svg>');
|
|
2201
|
+
closeBtn.addEventListener('click', onClose);
|
|
2202
|
+
|
|
2203
|
+
const docsLink = h('a', { href: DOCS_URL, target: '_blank', rel: 'noopener noreferrer', className: 'sdt-docs-link' });
|
|
2204
|
+
docsLink.appendChild(document.createTextNode('Docs'));
|
|
2205
|
+
const docsIcon = h('span', { className: 'sdt-docs-link-icon', 'aria-hidden': 'true' });
|
|
2206
|
+
setHtml(docsIcon, '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><path d="M7 17L17 7"/><path d="M7 7h10v10"/></svg>');
|
|
2207
|
+
docsLink.appendChild(docsIcon);
|
|
2208
|
+
|
|
2209
|
+
const trailingControls = h('div', { className: 'sdt-tabbar-actions' }, docsLink, closeBtn);
|
|
2210
|
+
|
|
2211
|
+
const tabBar = createTabBar(tabs, activeTab, (id) => {
|
|
2212
|
+
state.update({ activeTab: id as TabId });
|
|
2213
|
+
applyPanelMode(id as TabId, { animate: true });
|
|
2214
|
+
showTab(id as TabId);
|
|
2215
|
+
}, { trailing: trailingControls });
|
|
2216
|
+
inner.appendChild(tabBar.el);
|
|
2217
|
+
|
|
2218
|
+
const content = h('div', { className: 'sdt-content' });
|
|
2219
|
+
const layers = h('div', { className: 'sdt-tab-layers' });
|
|
2220
|
+
content.appendChild(layers);
|
|
2221
|
+
inner.appendChild(content);
|
|
2222
|
+
|
|
2223
|
+
const mountedPanes = new Map<TabId, HTMLElement>();
|
|
2224
|
+
const cleanups: Array<() => void> = [];
|
|
2225
|
+
|
|
2226
|
+
function mountTab(pane: HTMLElement, result: TabResult | HTMLElement) {
|
|
2227
|
+
if ('element' in result) {
|
|
2228
|
+
pane.appendChild(result.element);
|
|
2229
|
+
if (result.cleanup) {
|
|
2230
|
+
cleanups.push(result.cleanup);
|
|
2231
|
+
}
|
|
2232
|
+
} else {
|
|
2233
|
+
pane.appendChild(result);
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
function getOrCreatePane(tabId: TabId): HTMLElement {
|
|
2238
|
+
if (mountedPanes.has(tabId)) {
|
|
2239
|
+
return mountedPanes.get(tabId)!;
|
|
2240
|
+
}
|
|
2241
|
+
const pane = h('div', { className: 'sdt-tab-pane' });
|
|
2242
|
+
if (tabId === 'dashboard') {
|
|
2243
|
+
pane.classList.add('sdt-tab-pane-iframe');
|
|
2244
|
+
}
|
|
2245
|
+
switch (tabId) {
|
|
2246
|
+
case 'overview': {
|
|
2247
|
+
mountTab(pane, createOverviewTab(app));
|
|
2248
|
+
break;
|
|
2249
|
+
}
|
|
2250
|
+
case 'customize': {
|
|
2251
|
+
mountTab(pane, createComponentsTab(app));
|
|
2252
|
+
break;
|
|
2253
|
+
}
|
|
2254
|
+
case 'ai': {
|
|
2255
|
+
mountTab(pane, createAITab(app));
|
|
2256
|
+
break;
|
|
2257
|
+
}
|
|
2258
|
+
case 'console': {
|
|
2259
|
+
mountTab(pane, createConsoleTab(logStore));
|
|
2260
|
+
break;
|
|
2261
|
+
}
|
|
2262
|
+
case 'dashboard': {
|
|
2263
|
+
mountTab(pane, createDashboardTab(app));
|
|
2264
|
+
break;
|
|
2265
|
+
}
|
|
2266
|
+
case 'support': {
|
|
2267
|
+
mountTab(pane, createSupportTab(app));
|
|
2268
|
+
break;
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
mountedPanes.set(tabId, pane);
|
|
2272
|
+
layers.appendChild(pane);
|
|
2273
|
+
return pane;
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
function showTab(tabId: TabId) {
|
|
2277
|
+
const pane = getOrCreatePane(tabId);
|
|
2278
|
+
tabBar.setActive(tabId);
|
|
2279
|
+
for (const [, p] of mountedPanes) {
|
|
2280
|
+
p.classList.remove('sdt-tab-pane-active');
|
|
2281
|
+
}
|
|
2282
|
+
pane.classList.add('sdt-tab-pane-active');
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
showTab(activeTab);
|
|
2286
|
+
|
|
2287
|
+
function addResizeHandle(edge: 'top' | 'left' | 'top-left') {
|
|
2288
|
+
const handle = h('div', { className: `sdt-resize-handle sdt-resize-${edge}` });
|
|
2289
|
+
let startX = 0;
|
|
2290
|
+
let startY = 0;
|
|
2291
|
+
let startW = 0;
|
|
2292
|
+
let startH = 0;
|
|
2293
|
+
|
|
2294
|
+
handle.addEventListener('pointerdown', (e) => {
|
|
2295
|
+
e.preventDefault();
|
|
2296
|
+
if (panelAnimationTimeout !== null) {
|
|
2297
|
+
clearTimeout(panelAnimationTimeout);
|
|
2298
|
+
panelAnimationTimeout = null;
|
|
2299
|
+
}
|
|
2300
|
+
panel.classList.remove('sdt-panel-geometry-animated');
|
|
2301
|
+
handle.setPointerCapture(e.pointerId);
|
|
2302
|
+
startX = e.clientX;
|
|
2303
|
+
startY = e.clientY;
|
|
2304
|
+
startW = panel.offsetWidth;
|
|
2305
|
+
startH = panel.offsetHeight;
|
|
2306
|
+
});
|
|
2307
|
+
|
|
2308
|
+
handle.addEventListener('pointermove', (e) => {
|
|
2309
|
+
if (!handle.hasPointerCapture(e.pointerId)) return;
|
|
2310
|
+
const dx = startX - e.clientX;
|
|
2311
|
+
const dy = startY - e.clientY;
|
|
2312
|
+
if (edge === 'left' || edge === 'top-left') {
|
|
2313
|
+
const newW = Math.max(400, Math.min(startW + dx, window.innerWidth - 32));
|
|
2314
|
+
panel.style.width = newW + 'px';
|
|
2315
|
+
}
|
|
2316
|
+
if (edge === 'top' || edge === 'top-left') {
|
|
2317
|
+
const newH = Math.max(300, Math.min(startH + dy, window.innerHeight - 80));
|
|
2318
|
+
panel.style.height = newH + 'px';
|
|
2319
|
+
}
|
|
2320
|
+
});
|
|
2321
|
+
|
|
2322
|
+
handle.addEventListener('pointerup', (e) => {
|
|
2323
|
+
handle.releasePointerCapture(e.pointerId);
|
|
2324
|
+
state.update({ panelWidth: panel.offsetWidth, panelHeight: panel.offsetHeight });
|
|
2325
|
+
});
|
|
2326
|
+
|
|
2327
|
+
panel.appendChild(handle);
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
addResizeHandle('top');
|
|
2331
|
+
addResizeHandle('left');
|
|
2332
|
+
addResizeHandle('top-left');
|
|
2333
|
+
|
|
2334
|
+
panel.appendChild(inner);
|
|
2335
|
+
return {
|
|
2336
|
+
element: panel,
|
|
2337
|
+
cleanup: () => {
|
|
2338
|
+
if (panelAnimationTimeout !== null) {
|
|
2339
|
+
clearTimeout(panelAnimationTimeout);
|
|
2340
|
+
}
|
|
2341
|
+
for (const fn of cleanups) fn();
|
|
2342
|
+
},
|
|
2343
|
+
};
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
// ===========================================================================================
|
|
2347
|
+
// Main entry point
|
|
2348
|
+
// ===========================================================================================
|
|
2349
|
+
|
|
2350
|
+
export function createDevTool(app: StackClientApp<true>): () => void {
|
|
2351
|
+
if (typeof document === 'undefined' || typeof document.createElement !== 'function') {
|
|
2352
|
+
return () => {};
|
|
2353
|
+
}
|
|
2354
|
+
const body = Reflect.get(document, 'body');
|
|
2355
|
+
if (!hasAppendChild(body)) return () => {};
|
|
2356
|
+
|
|
2357
|
+
getGlobalDevToolInstance()?.cleanup();
|
|
2358
|
+
let existingRoot = document.getElementById(ROOT_ID);
|
|
2359
|
+
while (existingRoot !== null) {
|
|
2360
|
+
existingRoot.remove();
|
|
2361
|
+
existingRoot = document.getElementById(ROOT_ID);
|
|
2362
|
+
}
|
|
2363
|
+
|
|
2364
|
+
const root = document.createElement('div');
|
|
2365
|
+
root.id = ROOT_ID;
|
|
2366
|
+
body.appendChild(root);
|
|
2367
|
+
|
|
2368
|
+
const wrapper = h('div', { className: 'hexclave-devtool' });
|
|
2369
|
+
root.appendChild(wrapper);
|
|
2370
|
+
|
|
2371
|
+
const style = document.createElement('style');
|
|
2372
|
+
style.textContent = devToolCSS;
|
|
2373
|
+
wrapper.appendChild(style);
|
|
2374
|
+
|
|
2375
|
+
const state = createStateStore();
|
|
2376
|
+
const logStore = getGlobalLogStore();
|
|
2377
|
+
|
|
2378
|
+
let panel: { element: HTMLElement, cleanup: () => void } | null = null;
|
|
2379
|
+
|
|
2380
|
+
function closePanelAndPersistClosed() {
|
|
2381
|
+
closePanel();
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
function openPanel() {
|
|
2385
|
+
if (panel) return;
|
|
2386
|
+
panel = createPanel(app, state, logStore, closePanelAndPersistClosed);
|
|
2387
|
+
wrapper.appendChild(panel.element);
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
function closePanel() {
|
|
2391
|
+
if (!panel) return;
|
|
2392
|
+
state.update({ isOpen: false });
|
|
2393
|
+
const closing = panel;
|
|
2394
|
+
panel = null;
|
|
2395
|
+
closing.cleanup();
|
|
2396
|
+
closing.element.classList.add('sdt-panel-exiting');
|
|
2397
|
+
setTimeout(() => {
|
|
2398
|
+
if (wrapper.contains(closing.element)) {
|
|
2399
|
+
wrapper.removeChild(closing.element);
|
|
2400
|
+
}
|
|
2401
|
+
}, 150);
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
function togglePanel() {
|
|
2405
|
+
if (state.get().isOpen) {
|
|
2406
|
+
closePanel();
|
|
2407
|
+
} else {
|
|
2408
|
+
state.update({ isOpen: true });
|
|
2409
|
+
openPanel();
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2413
|
+
const trigger = createTrigger(togglePanel);
|
|
2414
|
+
wrapper.appendChild(trigger.element);
|
|
2415
|
+
|
|
2416
|
+
if (state.get().isOpen) {
|
|
2417
|
+
openPanel();
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
const removeRequestListener = app[hexclaveAppInternalsSymbol].addRequestListener((entry: RequestLogEntry) => {
|
|
2421
|
+
const timestamp = Date.now();
|
|
2422
|
+
logStore.addApiLog({
|
|
2423
|
+
id: nextId(),
|
|
2424
|
+
timestamp,
|
|
2425
|
+
method: entry.method,
|
|
2426
|
+
url: entry.path,
|
|
2427
|
+
status: entry.status,
|
|
2428
|
+
duration: entry.duration,
|
|
2429
|
+
error: entry.error,
|
|
2430
|
+
});
|
|
2431
|
+
if (entry.error) {
|
|
2432
|
+
logStore.addEventLog({ id: nextId(), timestamp, type: 'error', message: `Network error on ${entry.method} ${entry.path}: ${entry.error}` });
|
|
2433
|
+
} else if (entry.status && entry.status >= 400) {
|
|
2434
|
+
logStore.addEventLog({ id: nextId(), timestamp, type: 'error', message: `API error ${entry.status} on ${entry.method} ${entry.path}` });
|
|
2435
|
+
}
|
|
2436
|
+
});
|
|
2437
|
+
|
|
2438
|
+
let didCleanup = false;
|
|
2439
|
+
const instance: DevToolGlobalInstance = {
|
|
2440
|
+
cleanup: () => {
|
|
2441
|
+
if (didCleanup) return;
|
|
2442
|
+
didCleanup = true;
|
|
2443
|
+
if (getGlobalDevToolInstance() === instance) {
|
|
2444
|
+
setGlobalDevToolInstance(null);
|
|
2445
|
+
}
|
|
2446
|
+
trigger.cleanup();
|
|
2447
|
+
removeRequestListener();
|
|
2448
|
+
panel?.cleanup();
|
|
2449
|
+
if (root.parentNode) {
|
|
2450
|
+
root.parentNode.removeChild(root);
|
|
2451
|
+
}
|
|
2452
|
+
},
|
|
2453
|
+
};
|
|
2454
|
+
setGlobalDevToolInstance(instance);
|
|
2455
|
+
|
|
2456
|
+
return () => {
|
|
2457
|
+
instance.cleanup();
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2460
|
+
|