@nebulr-group/bridge-svelte 0.1.0-beta.0
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/LICENSE +21 -0
- package/README.md +63 -0
- package/dist/auth/route-guard.d.ts +2 -0
- package/dist/auth/route-guard.js +28 -0
- package/dist/client/BridgeBootstrap.d.ts +8 -0
- package/dist/client/BridgeBootstrap.js +105 -0
- package/dist/client/BridgeBootstrap.svelte +43 -0
- package/dist/client/BridgeBootstrap.svelte.d.ts +6 -0
- package/dist/client/components/FeatureFlag.svelte +37 -0
- package/dist/client/components/FeatureFlag.svelte.d.ts +15 -0
- package/dist/client/components/ProfileName.svelte +18 -0
- package/dist/client/components/ProfileName.svelte.d.ts +6 -0
- package/dist/client/components/developer/ApiTokenManagement.svelte +365 -0
- package/dist/client/components/developer/ApiTokenManagement.svelte.d.ts +6 -0
- package/dist/client/components/sdk-auth/ForgotPassword.svelte +170 -0
- package/dist/client/components/sdk-auth/ForgotPassword.svelte.d.ts +10 -0
- package/dist/client/components/sdk-auth/LoginForm.svelte +414 -0
- package/dist/client/components/sdk-auth/LoginForm.svelte.d.ts +25 -0
- package/dist/client/components/sdk-auth/MagicLink.svelte +92 -0
- package/dist/client/components/sdk-auth/MagicLink.svelte.d.ts +9 -0
- package/dist/client/components/sdk-auth/MfaChallenge.svelte +150 -0
- package/dist/client/components/sdk-auth/MfaChallenge.svelte.d.ts +9 -0
- package/dist/client/components/sdk-auth/MfaSetup.svelte +182 -0
- package/dist/client/components/sdk-auth/MfaSetup.svelte.d.ts +8 -0
- package/dist/client/components/sdk-auth/PasskeyLogin.svelte +99 -0
- package/dist/client/components/sdk-auth/PasskeyLogin.svelte.d.ts +10 -0
- package/dist/client/components/sdk-auth/PasskeyRequestSetupLink.svelte +83 -0
- package/dist/client/components/sdk-auth/PasskeyRequestSetupLink.svelte.d.ts +7 -0
- package/dist/client/components/sdk-auth/PasskeySetup.svelte +151 -0
- package/dist/client/components/sdk-auth/PasskeySetup.svelte.d.ts +11 -0
- package/dist/client/components/sdk-auth/SignupForm.svelte +119 -0
- package/dist/client/components/sdk-auth/SignupForm.svelte.d.ts +14 -0
- package/dist/client/components/sdk-auth/SsoButton.svelte +70 -0
- package/dist/client/components/sdk-auth/SsoButton.svelte.d.ts +13 -0
- package/dist/client/components/sdk-auth/SsoProviderIcon.svelte +56 -0
- package/dist/client/components/sdk-auth/SsoProviderIcon.svelte.d.ts +7 -0
- package/dist/client/components/sdk-auth/TenantSelector.svelte +83 -0
- package/dist/client/components/sdk-auth/TenantSelector.svelte.d.ts +11 -0
- package/dist/client/components/sdk-auth/WorkspaceSelector.svelte +108 -0
- package/dist/client/components/sdk-auth/WorkspaceSelector.svelte.d.ts +16 -0
- package/dist/client/components/sdk-auth/shared/Alert.svelte +17 -0
- package/dist/client/components/sdk-auth/shared/Alert.svelte.d.ts +9 -0
- package/dist/client/components/sdk-auth/shared/AuthFormWrapper.svelte +23 -0
- package/dist/client/components/sdk-auth/shared/AuthFormWrapper.svelte.d.ts +10 -0
- package/dist/client/components/sdk-auth/shared/Spinner.svelte +16 -0
- package/dist/client/components/sdk-auth/shared/Spinner.svelte.d.ts +7 -0
- package/dist/client/components/subscription/PlanSelector.svelte +204 -0
- package/dist/client/components/subscription/PlanSelector.svelte.d.ts +22 -0
- package/dist/client/components/team/TeamAddUserDialog.svelte +125 -0
- package/dist/client/components/team/TeamAddUserDialog.svelte.d.ts +17 -0
- package/dist/client/components/team/TeamConfirmDialog.svelte +80 -0
- package/dist/client/components/team/TeamConfirmDialog.svelte.d.ts +21 -0
- package/dist/client/components/team/TeamEditUserDialog.svelte +131 -0
- package/dist/client/components/team/TeamEditUserDialog.svelte.d.ts +19 -0
- package/dist/client/components/team/TeamManagementPanel.svelte +72 -0
- package/dist/client/components/team/TeamManagementPanel.svelte.d.ts +20 -0
- package/dist/client/components/team/TeamProfileForm.svelte +129 -0
- package/dist/client/components/team/TeamProfileForm.svelte.d.ts +7 -0
- package/dist/client/components/team/TeamUserActionsMenu.svelte +63 -0
- package/dist/client/components/team/TeamUserActionsMenu.svelte.d.ts +9 -0
- package/dist/client/components/team/TeamUserList.svelte +226 -0
- package/dist/client/components/team/TeamUserList.svelte.d.ts +7 -0
- package/dist/client/components/team/TeamWorkspaceForm.svelte +134 -0
- package/dist/client/components/team/TeamWorkspaceForm.svelte.d.ts +7 -0
- package/dist/client/stores/config.store.d.ts +6 -0
- package/dist/client/stores/config.store.js +76 -0
- package/dist/client/utils/cn.d.ts +1 -0
- package/dist/client/utils/cn.js +3 -0
- package/dist/core/bridge-instance.d.ts +52 -0
- package/dist/core/bridge-instance.js +160 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +39 -0
- package/dist/shared/feature-flag.d.ts +6 -0
- package/dist/shared/feature-flag.js +13 -0
- package/dist/shared/logger.d.ts +18 -0
- package/dist/shared/logger.js +32 -0
- package/dist/shared/profile.d.ts +18 -0
- package/dist/shared/profile.js +25 -0
- package/dist/shared/types/config.d.ts +42 -0
- package/dist/shared/types/config.js +1 -0
- package/dist/styles.css +1089 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Nebulr AB
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
|
|
2
|
+
## @nebulr-group/bridge-svelte
|
|
3
|
+
|
|
4
|
+
[](https://madewithsvelte.com/p/the-bridge/shield-link)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Bridge Svelte library. Add Bridge auth, feature flags, and payments to your SvelteKit 2 + Svelte 5 apps.
|
|
8
|
+
|
|
9
|
+
### Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm i @nebulr-group/bridge-svelte
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
16
|
+
|
|
17
|
+
See the `demo/` app in the monorepo for end-to-end wiring.
|
|
18
|
+
|
|
19
|
+
### Build
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm run build
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Artifacts are emitted to `dist/` via `svelte-package`.
|
|
27
|
+
|
|
28
|
+
### Release (branch-protected main)
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# 1) Create release branch
|
|
32
|
+
git checkout -b release/v0.1.0-beta.1
|
|
33
|
+
git push -u origin release/v0.1.0-beta.1
|
|
34
|
+
|
|
35
|
+
# 2) Open a PR: release/v0.1.0-beta.1 -> main, approve and merge
|
|
36
|
+
|
|
37
|
+
# 3) After merge to main, tag and push
|
|
38
|
+
git checkout main && git pull
|
|
39
|
+
git tag v0.1.0-beta.1
|
|
40
|
+
git push origin v0.1.0-beta.1
|
|
41
|
+
|
|
42
|
+
# 4) Monitor GitHub Actions "Publish to npm"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Commit signing (required)
|
|
46
|
+
|
|
47
|
+
Ensure your commits are verified before opening PRs:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Option A: SSH signing (recommended)
|
|
51
|
+
git config --global gpg.format ssh
|
|
52
|
+
git config --global user.signingkey ~/.ssh/id_ed25519.pub
|
|
53
|
+
git config --global commit.gpgsign true
|
|
54
|
+
|
|
55
|
+
# Option B: GPG signing
|
|
56
|
+
gpg --full-generate-key
|
|
57
|
+
gpg --list-secret-keys --keyid-format=long
|
|
58
|
+
git config --global user.signingkey <KEY_ID>
|
|
59
|
+
git config --global commit.gpgsign true
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### License
|
|
63
|
+
MIT © thebridgedev
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/lib/auth/route-guard.ts — thin wrapper delegating to auth-core via bridge-instance
|
|
2
|
+
import { getBridgeAuth } from '../core/bridge-instance.js';
|
|
3
|
+
import { getRouteGuardConfig } from '../client/stores/config.store.js';
|
|
4
|
+
export function createRouteGuard(flagsReady) {
|
|
5
|
+
const config = getRouteGuardConfig();
|
|
6
|
+
const guard = getBridgeAuth().createRouteGuard(config);
|
|
7
|
+
if (!flagsReady)
|
|
8
|
+
return guard;
|
|
9
|
+
// Wrap checkRouteRestrictions to await flagsReady before evaluating
|
|
10
|
+
return {
|
|
11
|
+
...guard,
|
|
12
|
+
async checkRouteRestrictions(pathname) {
|
|
13
|
+
await flagsReady;
|
|
14
|
+
return guard.checkRouteRestrictions(pathname);
|
|
15
|
+
},
|
|
16
|
+
async getNavigationDecision(pathname) {
|
|
17
|
+
if (guard.shouldRedirectToLogin(pathname)) {
|
|
18
|
+
return { type: 'login', loginUrl: guard.getLoginRedirect() };
|
|
19
|
+
}
|
|
20
|
+
await flagsReady;
|
|
21
|
+
const redirectTo = await guard.checkRouteRestrictions(pathname);
|
|
22
|
+
if (redirectTo) {
|
|
23
|
+
return { type: 'redirect', to: redirectTo };
|
|
24
|
+
}
|
|
25
|
+
return { type: 'allow' };
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RouteGuardConfig } from '../auth/route-guard.js';
|
|
2
|
+
import { waitForBridge as _waitForBridge } from '../core/bridge-instance.js';
|
|
3
|
+
import type { BridgeConfig } from '../shared/types/config.js';
|
|
4
|
+
export declare function bridgeBootstrap(url: URL, config: BridgeConfig | string, routeConfig?: RouteGuardConfig): Promise<{
|
|
5
|
+
flagsReady: Promise<void>;
|
|
6
|
+
} | undefined>;
|
|
7
|
+
export declare const bridgeReady: import("svelte/store").Readable<boolean>;
|
|
8
|
+
export { _waitForBridge as waitForBridge };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// src/lib/bridge/bootstrap.ts
|
|
2
|
+
import { isRedirect, redirect } from '@sveltejs/kit';
|
|
3
|
+
import { get } from 'svelte/store';
|
|
4
|
+
import { createRouteGuard } from '../auth/route-guard.js';
|
|
5
|
+
import { getBridgeAuth, bridgeReadyStore, markReady, waitForBridge as _waitForBridge, } from '../core/bridge-instance.js';
|
|
6
|
+
import { featureFlags } from '../shared/feature-flag.js';
|
|
7
|
+
import { logger } from '../shared/logger.js';
|
|
8
|
+
import { bridgeConfig, getConfig } from './stores/config.store.js';
|
|
9
|
+
export async function bridgeBootstrap(url, config, routeConfig = { rules: [], defaultAccess: 'protected' }) {
|
|
10
|
+
// If we've already completed bootstrap once, short-circuit
|
|
11
|
+
if (get(bridgeReadyStore)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const finalConfig = typeof config === 'string' ? { appId: config } : config;
|
|
15
|
+
// 1. Initialize configuration (synchronously) — this also calls initBridge()
|
|
16
|
+
bridgeConfig.initConfig(finalConfig, routeConfig);
|
|
17
|
+
// 1a. If we're on bridge OAuth callback route, let bridge dedicated route handle it
|
|
18
|
+
try {
|
|
19
|
+
const resolvedCallbackUrl = getConfig().callbackUrl;
|
|
20
|
+
const callbackPath = resolvedCallbackUrl ? new URL(resolvedCallbackUrl).pathname : null;
|
|
21
|
+
if (callbackPath && url.pathname === callbackPath) {
|
|
22
|
+
logger.debug('[bridgeBootstrap] callback route detected, skipping bootstrap flow');
|
|
23
|
+
const bridge = getBridgeAuth();
|
|
24
|
+
const code = url.searchParams.get('code');
|
|
25
|
+
logger.debug('[bridgeBootstrap] callback code check', { hasCode: !!code, pathname: url.pathname });
|
|
26
|
+
if (code) {
|
|
27
|
+
try {
|
|
28
|
+
logger.debug('[bridgeBootstrap] calling handleCallback');
|
|
29
|
+
await bridge.handleCallback(code);
|
|
30
|
+
// Verify tokens before redirect
|
|
31
|
+
const tokensAfterCallback = bridge.getTokens();
|
|
32
|
+
const isAuthAfterCallback = !!tokensAfterCallback?.accessToken;
|
|
33
|
+
logger.debug('[bridgeBootstrap] after handleCallback', {
|
|
34
|
+
hasTokens: !!tokensAfterCallback?.accessToken,
|
|
35
|
+
isAuthenticated: isAuthAfterCallback
|
|
36
|
+
});
|
|
37
|
+
// Redirect bridge user to bridge home page after bridge callback is handled
|
|
38
|
+
// Preserve payment status if present (from post-payment redirect)
|
|
39
|
+
const payment = url.searchParams.get('payment');
|
|
40
|
+
const redirectUrl = payment ? `/?payment=${payment}` : '/';
|
|
41
|
+
logger.debug('[bridgeBootstrap] redirecting to', { redirectUrl, payment });
|
|
42
|
+
redirect(303, redirectUrl);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
if (isRedirect(err)) {
|
|
46
|
+
throw err; // Re-throw redirect so SvelteKit can handle it
|
|
47
|
+
}
|
|
48
|
+
logger.error('[bridgeBootstrap] Auth callback error:', err);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
logger.warn('[bridgeBootstrap] callback route detected but no code parameter');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
if (isRedirect(e)) {
|
|
58
|
+
throw e; // Re-throw redirect so SvelteKit can handle it
|
|
59
|
+
}
|
|
60
|
+
logger.warn('[bridgeBootstrap] failed parsing callbackUrl', e);
|
|
61
|
+
}
|
|
62
|
+
// 2. Ensure tokens are fresh if needed
|
|
63
|
+
try {
|
|
64
|
+
const bridge = getBridgeAuth();
|
|
65
|
+
if (bridge.isAuthenticated()) {
|
|
66
|
+
await bridge.refreshTokens();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// Non-fatal — stale tokens will be caught by route guard
|
|
71
|
+
}
|
|
72
|
+
// 3. Fire flag fetch without awaiting so GQL queries can start in parallel.
|
|
73
|
+
// The flagsReady promise is passed to the guard and returned to callers
|
|
74
|
+
// so routes that need flags can still await before rendering.
|
|
75
|
+
// Swallow errors — feature flag failures should never crash the bootstrap.
|
|
76
|
+
const flagsReady = featureFlags.refresh().catch((err) => {
|
|
77
|
+
logger.warn('[bridgeBootstrap] Feature flags failed to load:', err);
|
|
78
|
+
});
|
|
79
|
+
// 4. Handle route guarding and redirects
|
|
80
|
+
const guard = createRouteGuard(flagsReady);
|
|
81
|
+
const bridge = getBridgeAuth();
|
|
82
|
+
const currentTokens = bridge.getTokens();
|
|
83
|
+
const currentAuth = !!currentTokens?.accessToken;
|
|
84
|
+
logger.debug('[bridgeBootstrap] before route guard check', {
|
|
85
|
+
pathname: url.pathname,
|
|
86
|
+
hasTokens: !!currentTokens?.accessToken,
|
|
87
|
+
isAuthenticated: currentAuth
|
|
88
|
+
});
|
|
89
|
+
const decision = await guard.getNavigationDecision(url.pathname);
|
|
90
|
+
logger.debug('[bridgeBootstrap] navigation decision', decision);
|
|
91
|
+
if (decision.type === 'login') {
|
|
92
|
+
const { loginRoute } = getConfig();
|
|
93
|
+
// SDK mode: consumer explicitly set loginRoute → redirect to in-app login view
|
|
94
|
+
// Hosted mode (default): no loginRoute → redirect to hosted auth portal
|
|
95
|
+
redirect(303, loginRoute ?? bridge.createLoginUrl());
|
|
96
|
+
}
|
|
97
|
+
if (decision.type === 'redirect' && url.pathname !== decision.to) {
|
|
98
|
+
redirect(303, decision.to);
|
|
99
|
+
}
|
|
100
|
+
logger.debug('[bridgeBootstrap] in bridge end');
|
|
101
|
+
markReady();
|
|
102
|
+
return { flagsReady };
|
|
103
|
+
}
|
|
104
|
+
export const bridgeReady = bridgeReadyStore;
|
|
105
|
+
export { _waitForBridge as waitForBridge };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { beforeNavigate, goto } from '$app/navigation';
|
|
3
|
+
import { onMount } from 'svelte';
|
|
4
|
+
import { createRouteGuard } from '../auth/route-guard.js';
|
|
5
|
+
import { getBridgeAuth } from '../core/bridge-instance.js';
|
|
6
|
+
import { getConfig } from './stores/config.store.js';
|
|
7
|
+
|
|
8
|
+
// Props: require config to be passed by consumer, now including onBootstrapComplete
|
|
9
|
+
let {onBootstrapComplete }: {
|
|
10
|
+
onBootstrapComplete?: () => void
|
|
11
|
+
} = $props();
|
|
12
|
+
|
|
13
|
+
const guard = createRouteGuard();
|
|
14
|
+
|
|
15
|
+
async function handleRoute(pathname: string, cancel?: () => void) {
|
|
16
|
+
const decision = await guard.getNavigationDecision(pathname);
|
|
17
|
+
if (decision.type === 'login') {
|
|
18
|
+
if (cancel) cancel();
|
|
19
|
+
const { loginRoute } = getConfig();
|
|
20
|
+
if (loginRoute) {
|
|
21
|
+
goto(loginRoute);
|
|
22
|
+
} else {
|
|
23
|
+
getBridgeAuth().login();
|
|
24
|
+
}
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (decision.type === 'redirect' && window.location.pathname !== decision.to) {
|
|
28
|
+
if (cancel) cancel();
|
|
29
|
+
window.location.href = decision.to;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
onMount(async () => {
|
|
35
|
+
// Auth-core manages auto-refresh internally — no startAutoRefresh() needed
|
|
36
|
+
if (onBootstrapComplete) onBootstrapComplete();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
beforeNavigate(async ({ to, cancel }) => {
|
|
40
|
+
if (!to) return;
|
|
41
|
+
await handleRoute(to.url.pathname, cancel);
|
|
42
|
+
});
|
|
43
|
+
</script>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { onMount } from 'svelte';
|
|
4
|
+
import { isFeatureEnabled } from '../../shared/feature-flag.js';
|
|
5
|
+
|
|
6
|
+
type FlagRenderArgs = { enabled: boolean; rawEnabled: boolean };
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
flagName,
|
|
10
|
+
forceLive = false,
|
|
11
|
+
negate = false,
|
|
12
|
+
renderWhenDisabled = false,
|
|
13
|
+
children
|
|
14
|
+
}: {
|
|
15
|
+
flagName: string;
|
|
16
|
+
forceLive?: boolean;
|
|
17
|
+
negate?: boolean;
|
|
18
|
+
renderWhenDisabled?: boolean;
|
|
19
|
+
children?: Snippet<[FlagRenderArgs]>;
|
|
20
|
+
} = $props();
|
|
21
|
+
|
|
22
|
+
let enabled = $state(false);
|
|
23
|
+
let rawEnabled = $derived(enabled);
|
|
24
|
+
let effectiveEnabled = $derived(negate ? !enabled : enabled);
|
|
25
|
+
|
|
26
|
+
onMount(async () => {
|
|
27
|
+
enabled = await isFeatureEnabled(flagName, forceLive);
|
|
28
|
+
});
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
{#if children}
|
|
32
|
+
{#if renderWhenDisabled}
|
|
33
|
+
{@render children({ enabled: effectiveEnabled, rawEnabled })}
|
|
34
|
+
{:else if effectiveEnabled}
|
|
35
|
+
{@render children({ enabled: true, rawEnabled })}
|
|
36
|
+
{/if}
|
|
37
|
+
{/if}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type FlagRenderArgs = {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
rawEnabled: boolean;
|
|
5
|
+
};
|
|
6
|
+
type $$ComponentProps = {
|
|
7
|
+
flagName: string;
|
|
8
|
+
forceLive?: boolean;
|
|
9
|
+
negate?: boolean;
|
|
10
|
+
renderWhenDisabled?: boolean;
|
|
11
|
+
children?: Snippet<[FlagRenderArgs]>;
|
|
12
|
+
};
|
|
13
|
+
declare const FeatureFlag: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
14
|
+
type FeatureFlag = ReturnType<typeof FeatureFlag>;
|
|
15
|
+
export default FeatureFlag;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { profileStore } from '../../shared/profile.js';
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<HTMLSpanElement> {}
|
|
6
|
+
|
|
7
|
+
let { class: className, style, ...rest }: Props = $props();
|
|
8
|
+
|
|
9
|
+
const { profile } = profileStore;
|
|
10
|
+
|
|
11
|
+
let displayName = $derived(
|
|
12
|
+
$profile?.fullName || $profile?.email || ''
|
|
13
|
+
);
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
{#if displayName}
|
|
17
|
+
<span class={className} {style} data-bridge-profile-name {...rest}>{displayName}</span>
|
|
18
|
+
{/if}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
interface Props extends HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
}
|
|
4
|
+
declare const ProfileName: import("svelte").Component<Props, {}, "">;
|
|
5
|
+
type ProfileName = ReturnType<typeof ProfileName>;
|
|
6
|
+
export default ProfileName;
|