create-sidekick-app 0.0.0-stage → 2.0.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.md +202 -0
- package/NOTICE +27 -0
- package/README.md +30 -2
- package/dist/index.js +59 -0
- package/package.json +69 -3
- package/template/base/ai-chat/.env.example +6 -0
- package/template/base/ai-chat/.prettierignore +2 -0
- package/template/base/ai-chat/.prettierrc.json +5 -0
- package/template/base/ai-chat/README.md +38 -0
- package/template/base/ai-chat/_gitignore +41 -0
- package/template/base/ai-chat/components.json +23 -0
- package/template/base/ai-chat/next.config.ts +5 -0
- package/template/base/ai-chat/package.json +61 -0
- package/template/base/ai-chat/postcss.config.mjs +5 -0
- package/template/base/ai-chat/src/app/api/chat/route.ts +141 -0
- package/template/base/ai-chat/src/app/api/instant/route.ts +5 -0
- package/template/base/ai-chat/src/app/chat/[id]/page.tsx +20 -0
- package/template/base/ai-chat/src/app/globals.css +124 -0
- package/template/base/ai-chat/src/app/layout.tsx +34 -0
- package/template/base/ai-chat/src/app/page.tsx +6 -0
- package/template/base/ai-chat/src/components/AuthGate.tsx +15 -0
- package/template/base/ai-chat/src/components/Chat.tsx +228 -0
- package/template/base/ai-chat/src/components/InstantProvider.tsx +18 -0
- package/template/base/ai-chat/src/components/Login.tsx +163 -0
- package/template/base/ai-chat/src/components/Sidebar.tsx +100 -0
- package/template/base/ai-chat/src/components/ai-elements/agent.tsx +142 -0
- package/template/base/ai-chat/src/components/ai-elements/artifact.tsx +149 -0
- package/template/base/ai-chat/src/components/ai-elements/attachments.tsx +427 -0
- package/template/base/ai-chat/src/components/ai-elements/audio-player.tsx +229 -0
- package/template/base/ai-chat/src/components/ai-elements/canvas.tsx +26 -0
- package/template/base/ai-chat/src/components/ai-elements/chain-of-thought.tsx +223 -0
- package/template/base/ai-chat/src/components/ai-elements/checkpoint.tsx +72 -0
- package/template/base/ai-chat/src/components/ai-elements/code-block.tsx +556 -0
- package/template/base/ai-chat/src/components/ai-elements/commit.tsx +449 -0
- package/template/base/ai-chat/src/components/ai-elements/confirmation.tsx +173 -0
- package/template/base/ai-chat/src/components/ai-elements/connection.tsx +28 -0
- package/template/base/ai-chat/src/components/ai-elements/context.tsx +410 -0
- package/template/base/ai-chat/src/components/ai-elements/controls.tsx +19 -0
- package/template/base/ai-chat/src/components/ai-elements/conversation.tsx +167 -0
- package/template/base/ai-chat/src/components/ai-elements/edge.tsx +144 -0
- package/template/base/ai-chat/src/components/ai-elements/environment-variables.tsx +325 -0
- package/template/base/ai-chat/src/components/ai-elements/file-tree.tsx +298 -0
- package/template/base/ai-chat/src/components/ai-elements/image.tsx +25 -0
- package/template/base/ai-chat/src/components/ai-elements/inline-citation.tsx +294 -0
- package/template/base/ai-chat/src/components/ai-elements/jsx-preview.tsx +250 -0
- package/template/base/ai-chat/src/components/ai-elements/message.tsx +356 -0
- package/template/base/ai-chat/src/components/ai-elements/mic-selector.tsx +372 -0
- package/template/base/ai-chat/src/components/ai-elements/model-selector.tsx +214 -0
- package/template/base/ai-chat/src/components/ai-elements/node.tsx +72 -0
- package/template/base/ai-chat/src/components/ai-elements/open-in-chat.tsx +367 -0
- package/template/base/ai-chat/src/components/ai-elements/package-info.tsx +235 -0
- package/template/base/ai-chat/src/components/ai-elements/panel.tsx +16 -0
- package/template/base/ai-chat/src/components/ai-elements/persona.tsx +280 -0
- package/template/base/ai-chat/src/components/ai-elements/plan.tsx +144 -0
- package/template/base/ai-chat/src/components/ai-elements/prompt-input.tsx +1341 -0
- package/template/base/ai-chat/src/components/ai-elements/queue.tsx +275 -0
- package/template/base/ai-chat/src/components/ai-elements/reasoning.tsx +229 -0
- package/template/base/ai-chat/src/components/ai-elements/sandbox.tsx +128 -0
- package/template/base/ai-chat/src/components/ai-elements/schema-display.tsx +473 -0
- package/template/base/ai-chat/src/components/ai-elements/shimmer.tsx +78 -0
- package/template/base/ai-chat/src/components/ai-elements/snippet.tsx +141 -0
- package/template/base/ai-chat/src/components/ai-elements/sources.tsx +78 -0
- package/template/base/ai-chat/src/components/ai-elements/speech-input.tsx +324 -0
- package/template/base/ai-chat/src/components/ai-elements/stack-trace.tsx +531 -0
- package/template/base/ai-chat/src/components/ai-elements/suggestion.tsx +55 -0
- package/template/base/ai-chat/src/components/ai-elements/task.tsx +88 -0
- package/template/base/ai-chat/src/components/ai-elements/terminal.tsx +277 -0
- package/template/base/ai-chat/src/components/ai-elements/test-results.tsx +497 -0
- package/template/base/ai-chat/src/components/ai-elements/tool.tsx +174 -0
- package/template/base/ai-chat/src/components/ai-elements/toolbar.tsx +17 -0
- package/template/base/ai-chat/src/components/ai-elements/transcription.tsx +126 -0
- package/template/base/ai-chat/src/components/ai-elements/voice-selector.tsx +525 -0
- package/template/base/ai-chat/src/components/ai-elements/web-preview.tsx +282 -0
- package/template/base/ai-chat/src/components/ui/accordion.tsx +66 -0
- package/template/base/ai-chat/src/components/ui/alert.tsx +66 -0
- package/template/base/ai-chat/src/components/ui/avatar.tsx +109 -0
- package/template/base/ai-chat/src/components/ui/badge.tsx +48 -0
- package/template/base/ai-chat/src/components/ui/button-group.tsx +83 -0
- package/template/base/ai-chat/src/components/ui/button.tsx +64 -0
- package/template/base/ai-chat/src/components/ui/card.tsx +92 -0
- package/template/base/ai-chat/src/components/ui/carousel.tsx +241 -0
- package/template/base/ai-chat/src/components/ui/collapsible.tsx +33 -0
- package/template/base/ai-chat/src/components/ui/command.tsx +184 -0
- package/template/base/ai-chat/src/components/ui/dialog.tsx +158 -0
- package/template/base/ai-chat/src/components/ui/dropdown-menu.tsx +257 -0
- package/template/base/ai-chat/src/components/ui/hover-card.tsx +44 -0
- package/template/base/ai-chat/src/components/ui/input-group.tsx +170 -0
- package/template/base/ai-chat/src/components/ui/input.tsx +21 -0
- package/template/base/ai-chat/src/components/ui/popover.tsx +89 -0
- package/template/base/ai-chat/src/components/ui/progress.tsx +31 -0
- package/template/base/ai-chat/src/components/ui/scroll-area.tsx +58 -0
- package/template/base/ai-chat/src/components/ui/select.tsx +190 -0
- package/template/base/ai-chat/src/components/ui/separator.tsx +28 -0
- package/template/base/ai-chat/src/components/ui/spinner.tsx +16 -0
- package/template/base/ai-chat/src/components/ui/switch.tsx +35 -0
- package/template/base/ai-chat/src/components/ui/tabs.tsx +91 -0
- package/template/base/ai-chat/src/components/ui/textarea.tsx +18 -0
- package/template/base/ai-chat/src/components/ui/tooltip.tsx +57 -0
- package/template/base/ai-chat/src/instant.perms.ts +34 -0
- package/template/base/ai-chat/src/instant.schema.ts +107 -0
- package/template/base/ai-chat/src/lib/adminDb.ts +8 -0
- package/template/base/ai-chat/src/lib/db.ts +8 -0
- package/template/base/ai-chat/src/lib/mockModel.ts +119 -0
- package/template/base/ai-chat/src/lib/utils.ts +6 -0
- package/template/base/ai-chat/tsconfig.json +33 -0
- package/template/base/bun-react/.env.example +2 -0
- package/template/base/bun-react/README.md +12 -0
- package/template/base/bun-react/_gitignore +34 -0
- package/template/base/bun-react/bun-env.d.ts +17 -0
- package/template/base/bun-react/bunfig.toml +4 -0
- package/template/base/bun-react/package.json +22 -0
- package/template/base/bun-react/src/App.tsx +168 -0
- package/template/base/bun-react/src/frontend.tsx +20 -0
- package/template/base/bun-react/src/getUnusedPort.ts +32 -0
- package/template/base/bun-react/src/index.css +25 -0
- package/template/base/bun-react/src/index.html +13 -0
- package/template/base/bun-react/src/index.ts +21 -0
- package/template/base/bun-react/src/instant.perms.ts +24 -0
- package/template/base/bun-react/src/instant.schema.ts +46 -0
- package/template/base/bun-react/src/lib/db.ts +8 -0
- package/template/base/bun-react/src/logo.svg +1 -0
- package/template/base/bun-react/tsconfig.json +36 -0
- package/template/base/expo/.env.example +2 -0
- package/template/base/expo/README.md +18 -0
- package/template/base/expo/_gitignore +41 -0
- package/template/base/expo/app/+not-found.tsx +16 -0
- package/template/base/expo/app/_layout.tsx +37 -0
- package/template/base/expo/app/index.tsx +64 -0
- package/template/base/expo/app.json +42 -0
- package/template/base/expo/assets/fonts/SpaceMono-Regular.ttf +0 -0
- package/template/base/expo/assets/images/adaptive-icon.png +0 -0
- package/template/base/expo/assets/images/favicon.png +0 -0
- package/template/base/expo/assets/images/icon.png +0 -0
- package/template/base/expo/assets/images/partial-react-logo.png +0 -0
- package/template/base/expo/assets/images/react-logo.png +0 -0
- package/template/base/expo/assets/images/react-logo@2x.png +0 -0
- package/template/base/expo/assets/images/react-logo@3x.png +0 -0
- package/template/base/expo/assets/images/splash-icon.png +0 -0
- package/template/base/expo/babel.config.js +12 -0
- package/template/base/expo/constants/Colors.ts +26 -0
- package/template/base/expo/eslint.config.js +10 -0
- package/template/base/expo/global.css +3 -0
- package/template/base/expo/hooks/useColorScheme.ts +1 -0
- package/template/base/expo/hooks/useColorScheme.web.ts +21 -0
- package/template/base/expo/hooks/useThemeColor.ts +21 -0
- package/template/base/expo/instant.perms.ts +24 -0
- package/template/base/expo/instant.schema.ts +44 -0
- package/template/base/expo/lib/db.ts +7 -0
- package/template/base/expo/metro.config.js +6 -0
- package/template/base/expo/nativewind-env.d.ts +1 -0
- package/template/base/expo/package.json +57 -0
- package/template/base/expo/scripts/reset-project.js +112 -0
- package/template/base/expo/tailwind.config.js +9 -0
- package/template/base/expo/tsconfig.json +18 -0
- package/template/base/next-js-app-dir/.env.example +2 -0
- package/template/base/next-js-app-dir/README.md +18 -0
- package/template/base/next-js-app-dir/_gitignore +41 -0
- package/template/base/next-js-app-dir/next.config.ts +7 -0
- package/template/base/next-js-app-dir/package.json +27 -0
- package/template/base/next-js-app-dir/postcss.config.mjs +5 -0
- package/template/base/next-js-app-dir/public/file.svg +1 -0
- package/template/base/next-js-app-dir/public/globe.svg +1 -0
- package/template/base/next-js-app-dir/public/next.svg +1 -0
- package/template/base/next-js-app-dir/public/vercel.svg +1 -0
- package/template/base/next-js-app-dir/public/window.svg +1 -0
- package/template/base/next-js-app-dir/src/app/favicon.ico +0 -0
- package/template/base/next-js-app-dir/src/app/globals.css +26 -0
- package/template/base/next-js-app-dir/src/app/layout.tsx +34 -0
- package/template/base/next-js-app-dir/src/app/page.tsx +169 -0
- package/template/base/next-js-app-dir/src/instant.perms.ts +24 -0
- package/template/base/next-js-app-dir/src/instant.schema.ts +50 -0
- package/template/base/next-js-app-dir/src/lib/db.ts +8 -0
- package/template/base/next-js-app-dir/tsconfig.json +41 -0
- package/template/base/solidjs-vite/README.md +15 -0
- package/template/base/solidjs-vite/_gitignore +25 -0
- package/template/base/solidjs-vite/index.html +15 -0
- package/template/base/solidjs-vite/package.json +25 -0
- package/template/base/solidjs-vite/src/App.tsx +171 -0
- package/template/base/solidjs-vite/src/index.css +25 -0
- package/template/base/solidjs-vite/src/index.tsx +16 -0
- package/template/base/solidjs-vite/src/instant.perms.ts +24 -0
- package/template/base/solidjs-vite/src/instant.schema.ts +46 -0
- package/template/base/solidjs-vite/src/lib/db.ts +8 -0
- package/template/base/solidjs-vite/tsconfig.json +20 -0
- package/template/base/solidjs-vite/vite.config.ts +11 -0
- package/template/base/sveltekit/README.md +15 -0
- package/template/base/sveltekit/_gitignore +26 -0
- package/template/base/sveltekit/package.json +25 -0
- package/template/base/sveltekit/src/app.css +25 -0
- package/template/base/sveltekit/src/app.html +11 -0
- package/template/base/sveltekit/src/instant.perms.ts +24 -0
- package/template/base/sveltekit/src/instant.schema.ts +46 -0
- package/template/base/sveltekit/src/lib/db.ts +8 -0
- package/template/base/sveltekit/src/routes/+layout.svelte +6 -0
- package/template/base/sveltekit/src/routes/+page.svelte +236 -0
- package/template/base/sveltekit/src/routes/+page.ts +1 -0
- package/template/base/sveltekit/svelte.config.js +10 -0
- package/template/base/sveltekit/tsconfig.json +14 -0
- package/template/base/sveltekit/vite.config.ts +7 -0
- package/template/base/tanstack-start/.cta.json +12 -0
- package/template/base/tanstack-start/README.md +17 -0
- package/template/base/tanstack-start/_gitignore +13 -0
- package/template/base/tanstack-start/package.json +43 -0
- package/template/base/tanstack-start/public/favicon.ico +0 -0
- package/template/base/tanstack-start/public/logo192.png +0 -0
- package/template/base/tanstack-start/public/logo512.png +0 -0
- package/template/base/tanstack-start/public/manifest.json +25 -0
- package/template/base/tanstack-start/public/robots.txt +3 -0
- package/template/base/tanstack-start/public/tanstack-circle-logo.png +0 -0
- package/template/base/tanstack-start/public/tanstack-word-logo-white.svg +1 -0
- package/template/base/tanstack-start/src/components/Header.tsx +21 -0
- package/template/base/tanstack-start/src/instant.perms.ts +24 -0
- package/template/base/tanstack-start/src/instant.schema.ts +50 -0
- package/template/base/tanstack-start/src/lib/adminDb.ts +12 -0
- package/template/base/tanstack-start/src/lib/db.ts +9 -0
- package/template/base/tanstack-start/src/logo.svg +12 -0
- package/template/base/tanstack-start/src/routeTree.gen.ts +104 -0
- package/template/base/tanstack-start/src/router.tsx +22 -0
- package/template/base/tanstack-start/src/routes/__root.tsx +70 -0
- package/template/base/tanstack-start/src/routes/api/instant.ts +18 -0
- package/template/base/tanstack-start/src/routes/index.tsx +238 -0
- package/template/base/tanstack-start/src/routes/login.tsx +140 -0
- package/template/base/tanstack-start/src/styles.css +18 -0
- package/template/base/tanstack-start/tsconfig.json +28 -0
- package/template/base/tanstack-start/vite.config.ts +33 -0
- package/template/base/tanstack-start-with-tanstack-query/.cta.json +12 -0
- package/template/base/tanstack-start-with-tanstack-query/README.md +18 -0
- package/template/base/tanstack-start-with-tanstack-query/_gitignore +13 -0
- package/template/base/tanstack-start-with-tanstack-query/package.json +46 -0
- package/template/base/tanstack-start-with-tanstack-query/public/favicon.ico +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/logo192.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/logo512.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/manifest.json +25 -0
- package/template/base/tanstack-start-with-tanstack-query/public/robots.txt +3 -0
- package/template/base/tanstack-start-with-tanstack-query/public/tanstack-circle-logo.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/tanstack-word-logo-white.svg +1 -0
- package/template/base/tanstack-start-with-tanstack-query/src/components/Header.tsx +21 -0
- package/template/base/tanstack-start-with-tanstack-query/src/instant.perms.ts +24 -0
- package/template/base/tanstack-start-with-tanstack-query/src/instant.schema.ts +50 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/adminDb.ts +9 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/db.ts +11 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/instantQuery.ts +93 -0
- package/template/base/tanstack-start-with-tanstack-query/src/logo.svg +12 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routeTree.gen.ts +104 -0
- package/template/base/tanstack-start-with-tanstack-query/src/router.tsx +108 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/__root.tsx +76 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/api/instant.ts +16 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/index.tsx +231 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/login.tsx +140 -0
- package/template/base/tanstack-start-with-tanstack-query/src/styles.css +17 -0
- package/template/base/tanstack-start-with-tanstack-query/tsconfig.json +28 -0
- package/template/base/tanstack-start-with-tanstack-query/vite.config.ts +33 -0
- package/template/base/vite-react/README.md +16 -0
- package/template/base/vite-react/_gitignore +26 -0
- package/template/base/vite-react/eslint.config.js +23 -0
- package/template/base/vite-react/index.html +13 -0
- package/template/base/vite-react/package.json +35 -0
- package/template/base/vite-react/public/favicon.svg +1 -0
- package/template/base/vite-react/src/App.tsx +167 -0
- package/template/base/vite-react/src/index.css +1 -0
- package/template/base/vite-react/src/instant.perms.ts +24 -0
- package/template/base/vite-react/src/instant.schema.ts +51 -0
- package/template/base/vite-react/src/lib/db.ts +8 -0
- package/template/base/vite-react/src/main.tsx +10 -0
- package/template/base/vite-react/tsconfig.app.json +25 -0
- package/template/base/vite-react/tsconfig.json +7 -0
- package/template/base/vite-react/tsconfig.node.json +24 -0
- package/template/base/vite-react/vite.config.ts +8 -0
- package/template/base/vite-vanilla/.env.example +2 -0
- package/template/base/vite-vanilla/README.md +17 -0
- package/template/base/vite-vanilla/_gitignore +25 -0
- package/template/base/vite-vanilla/index.html +13 -0
- package/template/base/vite-vanilla/package.json +20 -0
- package/template/base/vite-vanilla/pnpm-lock.yaml +707 -0
- package/template/base/vite-vanilla/public/vite.svg +1 -0
- package/template/base/vite-vanilla/src/instant.perms.ts +24 -0
- package/template/base/vite-vanilla/src/instant.schema.ts +50 -0
- package/template/base/vite-vanilla/src/lib/db.ts +11 -0
- package/template/base/vite-vanilla/src/main.ts +242 -0
- package/template/base/vite-vanilla/src/style.css +96 -0
- package/template/base/vite-vanilla/src/typescript.svg +1 -0
- package/template/base/vite-vanilla/src/vite-env.d.ts +1 -0
- package/template/base/vite-vanilla/tsconfig.json +24 -0
- package/template/base/vue-vite/README.md +15 -0
- package/template/base/vue-vite/_gitignore +43 -0
- package/template/base/vue-vite/env.d.ts +1 -0
- package/template/base/vue-vite/index.html +12 -0
- package/template/base/vue-vite/package.json +34 -0
- package/template/base/vue-vite/src/App.vue +238 -0
- package/template/base/vue-vite/src/assets/main.css +25 -0
- package/template/base/vue-vite/src/instant.perms.ts +24 -0
- package/template/base/vue-vite/src/instant.schema.ts +46 -0
- package/template/base/vue-vite/src/lib/db.ts +8 -0
- package/template/base/vue-vite/src/main.ts +6 -0
- package/template/base/vue-vite/tsconfig.app.json +15 -0
- package/template/base/vue-vite/tsconfig.json +11 -0
- package/template/base/vue-vite/tsconfig.node.json +27 -0
- package/template/base/vue-vite/vite.config.ts +16 -0
- package/template/rules/AGENTS.md +436 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { EdgeProps, InternalNode, Node } from '@xyflow/react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BaseEdge,
|
|
5
|
+
getBezierPath,
|
|
6
|
+
getSimpleBezierPath,
|
|
7
|
+
Position,
|
|
8
|
+
useInternalNode,
|
|
9
|
+
} from '@xyflow/react';
|
|
10
|
+
|
|
11
|
+
const Temporary = ({
|
|
12
|
+
id,
|
|
13
|
+
sourceX,
|
|
14
|
+
sourceY,
|
|
15
|
+
targetX,
|
|
16
|
+
targetY,
|
|
17
|
+
sourcePosition,
|
|
18
|
+
targetPosition,
|
|
19
|
+
}: EdgeProps) => {
|
|
20
|
+
const [edgePath] = getSimpleBezierPath({
|
|
21
|
+
sourcePosition,
|
|
22
|
+
sourceX,
|
|
23
|
+
sourceY,
|
|
24
|
+
targetPosition,
|
|
25
|
+
targetX,
|
|
26
|
+
targetY,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<BaseEdge
|
|
31
|
+
className="stroke-ring stroke-1"
|
|
32
|
+
id={id}
|
|
33
|
+
path={edgePath}
|
|
34
|
+
style={{
|
|
35
|
+
strokeDasharray: '5, 5',
|
|
36
|
+
}}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const getHandleCoordsByPosition = (
|
|
42
|
+
node: InternalNode<Node>,
|
|
43
|
+
handlePosition: Position,
|
|
44
|
+
) => {
|
|
45
|
+
// Choose the handle type based on position - Left is for target, Right is for source
|
|
46
|
+
const handleType = handlePosition === Position.Left ? 'target' : 'source';
|
|
47
|
+
|
|
48
|
+
const handle = node.internals.handleBounds?.[handleType]?.find(
|
|
49
|
+
(h) => h.position === handlePosition,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
if (!handle) {
|
|
53
|
+
return [0, 0] as const;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let offsetX = handle.width / 2;
|
|
57
|
+
let offsetY = handle.height / 2;
|
|
58
|
+
|
|
59
|
+
// this is a tiny detail to make the markerEnd of an edge visible.
|
|
60
|
+
// The handle position that gets calculated has the origin top-left, so depending which side we are using, we add a little offset
|
|
61
|
+
// when the handlePosition is Position.Right for example, we need to add an offset as big as the handle itself in order to get the correct position
|
|
62
|
+
switch (handlePosition) {
|
|
63
|
+
case Position.Left: {
|
|
64
|
+
offsetX = 0;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
case Position.Right: {
|
|
68
|
+
offsetX = handle.width;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case Position.Top: {
|
|
72
|
+
offsetY = 0;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case Position.Bottom: {
|
|
76
|
+
offsetY = handle.height;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
default: {
|
|
80
|
+
throw new Error(`Invalid handle position: ${handlePosition}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const x = node.internals.positionAbsolute.x + handle.x + offsetX;
|
|
85
|
+
const y = node.internals.positionAbsolute.y + handle.y + offsetY;
|
|
86
|
+
|
|
87
|
+
return [x, y] as const;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const getEdgeParams = (
|
|
91
|
+
source: InternalNode<Node>,
|
|
92
|
+
target: InternalNode<Node>,
|
|
93
|
+
) => {
|
|
94
|
+
const sourcePos = Position.Right;
|
|
95
|
+
const [sx, sy] = getHandleCoordsByPosition(source, sourcePos);
|
|
96
|
+
const targetPos = Position.Left;
|
|
97
|
+
const [tx, ty] = getHandleCoordsByPosition(target, targetPos);
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
sourcePos,
|
|
101
|
+
sx,
|
|
102
|
+
sy,
|
|
103
|
+
targetPos,
|
|
104
|
+
tx,
|
|
105
|
+
ty,
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const Animated = ({ id, source, target, markerEnd, style }: EdgeProps) => {
|
|
110
|
+
const sourceNode = useInternalNode(source);
|
|
111
|
+
const targetNode = useInternalNode(target);
|
|
112
|
+
|
|
113
|
+
if (!(sourceNode && targetNode)) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const { sx, sy, tx, ty, sourcePos, targetPos } = getEdgeParams(
|
|
118
|
+
sourceNode,
|
|
119
|
+
targetNode,
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const [edgePath] = getBezierPath({
|
|
123
|
+
sourcePosition: sourcePos,
|
|
124
|
+
sourceX: sx,
|
|
125
|
+
sourceY: sy,
|
|
126
|
+
targetPosition: targetPos,
|
|
127
|
+
targetX: tx,
|
|
128
|
+
targetY: ty,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<>
|
|
133
|
+
<BaseEdge id={id} markerEnd={markerEnd} path={edgePath} style={style} />
|
|
134
|
+
<circle fill="var(--primary)" r="4">
|
|
135
|
+
<animateMotion dur="2s" path={edgePath} repeatCount="indefinite" />
|
|
136
|
+
</circle>
|
|
137
|
+
</>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export const Edge = {
|
|
142
|
+
Animated,
|
|
143
|
+
Temporary,
|
|
144
|
+
};
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { ComponentProps, HTMLAttributes } from 'react';
|
|
4
|
+
|
|
5
|
+
import { Badge } from '@/components/ui/badge';
|
|
6
|
+
import { Button } from '@/components/ui/button';
|
|
7
|
+
import { Switch } from '@/components/ui/switch';
|
|
8
|
+
import { cn } from '@/lib/utils';
|
|
9
|
+
import { CheckIcon, CopyIcon, EyeIcon, EyeOffIcon } from 'lucide-react';
|
|
10
|
+
import {
|
|
11
|
+
createContext,
|
|
12
|
+
useCallback,
|
|
13
|
+
useContext,
|
|
14
|
+
useEffect,
|
|
15
|
+
useMemo,
|
|
16
|
+
useRef,
|
|
17
|
+
useState,
|
|
18
|
+
} from 'react';
|
|
19
|
+
|
|
20
|
+
interface EnvironmentVariablesContextType {
|
|
21
|
+
showValues: boolean;
|
|
22
|
+
setShowValues: (show: boolean) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Default noop for context default value
|
|
26
|
+
// oxlint-disable-next-line eslint(no-empty-function)
|
|
27
|
+
const noop = () => {};
|
|
28
|
+
|
|
29
|
+
const EnvironmentVariablesContext =
|
|
30
|
+
createContext<EnvironmentVariablesContextType>({
|
|
31
|
+
setShowValues: noop,
|
|
32
|
+
showValues: false,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export type EnvironmentVariablesProps = HTMLAttributes<HTMLDivElement> & {
|
|
36
|
+
showValues?: boolean;
|
|
37
|
+
defaultShowValues?: boolean;
|
|
38
|
+
onShowValuesChange?: (show: boolean) => void;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const EnvironmentVariables = ({
|
|
42
|
+
showValues: controlledShowValues,
|
|
43
|
+
defaultShowValues = false,
|
|
44
|
+
onShowValuesChange,
|
|
45
|
+
className,
|
|
46
|
+
children,
|
|
47
|
+
...props
|
|
48
|
+
}: EnvironmentVariablesProps) => {
|
|
49
|
+
const [internalShowValues, setInternalShowValues] =
|
|
50
|
+
useState(defaultShowValues);
|
|
51
|
+
const showValues = controlledShowValues ?? internalShowValues;
|
|
52
|
+
|
|
53
|
+
const setShowValues = useCallback(
|
|
54
|
+
(show: boolean) => {
|
|
55
|
+
setInternalShowValues(show);
|
|
56
|
+
onShowValuesChange?.(show);
|
|
57
|
+
},
|
|
58
|
+
[onShowValuesChange],
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const contextValue = useMemo(
|
|
62
|
+
() => ({ setShowValues, showValues }),
|
|
63
|
+
[setShowValues, showValues],
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<EnvironmentVariablesContext.Provider value={contextValue}>
|
|
68
|
+
<div
|
|
69
|
+
className={cn('bg-background rounded-lg border', className)}
|
|
70
|
+
{...props}
|
|
71
|
+
>
|
|
72
|
+
{children}
|
|
73
|
+
</div>
|
|
74
|
+
</EnvironmentVariablesContext.Provider>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type EnvironmentVariablesHeaderProps = HTMLAttributes<HTMLDivElement>;
|
|
79
|
+
|
|
80
|
+
export const EnvironmentVariablesHeader = ({
|
|
81
|
+
className,
|
|
82
|
+
children,
|
|
83
|
+
...props
|
|
84
|
+
}: EnvironmentVariablesHeaderProps) => (
|
|
85
|
+
<div
|
|
86
|
+
className={cn(
|
|
87
|
+
'flex items-center justify-between border-b px-4 py-3',
|
|
88
|
+
className,
|
|
89
|
+
)}
|
|
90
|
+
{...props}
|
|
91
|
+
>
|
|
92
|
+
{children}
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
export type EnvironmentVariablesTitleProps = HTMLAttributes<HTMLHeadingElement>;
|
|
97
|
+
|
|
98
|
+
export const EnvironmentVariablesTitle = ({
|
|
99
|
+
className,
|
|
100
|
+
children,
|
|
101
|
+
...props
|
|
102
|
+
}: EnvironmentVariablesTitleProps) => (
|
|
103
|
+
<h3 className={cn('text-sm font-medium', className)} {...props}>
|
|
104
|
+
{children ?? 'Environment Variables'}
|
|
105
|
+
</h3>
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
export type EnvironmentVariablesToggleProps = ComponentProps<typeof Switch>;
|
|
109
|
+
|
|
110
|
+
export const EnvironmentVariablesToggle = ({
|
|
111
|
+
className,
|
|
112
|
+
...props
|
|
113
|
+
}: EnvironmentVariablesToggleProps) => {
|
|
114
|
+
const { showValues, setShowValues } = useContext(EnvironmentVariablesContext);
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<div className={cn('flex items-center gap-2', className)}>
|
|
118
|
+
<span className="text-muted-foreground text-xs">
|
|
119
|
+
{showValues ? <EyeIcon size={14} /> : <EyeOffIcon size={14} />}
|
|
120
|
+
</span>
|
|
121
|
+
<Switch
|
|
122
|
+
aria-label="Toggle value visibility"
|
|
123
|
+
checked={showValues}
|
|
124
|
+
onCheckedChange={setShowValues}
|
|
125
|
+
{...props}
|
|
126
|
+
/>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export type EnvironmentVariablesContentProps = HTMLAttributes<HTMLDivElement>;
|
|
132
|
+
|
|
133
|
+
export const EnvironmentVariablesContent = ({
|
|
134
|
+
className,
|
|
135
|
+
children,
|
|
136
|
+
...props
|
|
137
|
+
}: EnvironmentVariablesContentProps) => (
|
|
138
|
+
<div className={cn('divide-y', className)} {...props}>
|
|
139
|
+
{children}
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
interface EnvironmentVariableContextType {
|
|
144
|
+
name: string;
|
|
145
|
+
value: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const EnvironmentVariableContext =
|
|
149
|
+
createContext<EnvironmentVariableContextType>({
|
|
150
|
+
name: '',
|
|
151
|
+
value: '',
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
export type EnvironmentVariableProps = HTMLAttributes<HTMLDivElement> & {
|
|
155
|
+
name: string;
|
|
156
|
+
value: string;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export const EnvironmentVariable = ({
|
|
160
|
+
name,
|
|
161
|
+
value,
|
|
162
|
+
className,
|
|
163
|
+
children,
|
|
164
|
+
...props
|
|
165
|
+
}: EnvironmentVariableProps) => {
|
|
166
|
+
const envVarContextValue = useMemo(() => ({ name, value }), [name, value]);
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<EnvironmentVariableContext.Provider value={envVarContextValue}>
|
|
170
|
+
<div
|
|
171
|
+
className={cn(
|
|
172
|
+
'flex items-center justify-between gap-4 px-4 py-3',
|
|
173
|
+
className,
|
|
174
|
+
)}
|
|
175
|
+
{...props}
|
|
176
|
+
>
|
|
177
|
+
{children ?? (
|
|
178
|
+
<>
|
|
179
|
+
<div className="flex items-center gap-2">
|
|
180
|
+
<EnvironmentVariableName />
|
|
181
|
+
</div>
|
|
182
|
+
<EnvironmentVariableValue />
|
|
183
|
+
</>
|
|
184
|
+
)}
|
|
185
|
+
</div>
|
|
186
|
+
</EnvironmentVariableContext.Provider>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export type EnvironmentVariableGroupProps = HTMLAttributes<HTMLDivElement>;
|
|
191
|
+
|
|
192
|
+
export const EnvironmentVariableGroup = ({
|
|
193
|
+
className,
|
|
194
|
+
children,
|
|
195
|
+
...props
|
|
196
|
+
}: EnvironmentVariableGroupProps) => (
|
|
197
|
+
<div className={cn('flex items-center gap-2', className)} {...props}>
|
|
198
|
+
{children}
|
|
199
|
+
</div>
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
export type EnvironmentVariableNameProps = HTMLAttributes<HTMLSpanElement>;
|
|
203
|
+
|
|
204
|
+
export const EnvironmentVariableName = ({
|
|
205
|
+
className,
|
|
206
|
+
children,
|
|
207
|
+
...props
|
|
208
|
+
}: EnvironmentVariableNameProps) => {
|
|
209
|
+
const { name } = useContext(EnvironmentVariableContext);
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<span className={cn('font-mono text-sm', className)} {...props}>
|
|
213
|
+
{children ?? name}
|
|
214
|
+
</span>
|
|
215
|
+
);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export type EnvironmentVariableValueProps = HTMLAttributes<HTMLSpanElement>;
|
|
219
|
+
|
|
220
|
+
export const EnvironmentVariableValue = ({
|
|
221
|
+
className,
|
|
222
|
+
children,
|
|
223
|
+
...props
|
|
224
|
+
}: EnvironmentVariableValueProps) => {
|
|
225
|
+
const { value } = useContext(EnvironmentVariableContext);
|
|
226
|
+
const { showValues } = useContext(EnvironmentVariablesContext);
|
|
227
|
+
|
|
228
|
+
const displayValue = showValues
|
|
229
|
+
? value
|
|
230
|
+
: '•'.repeat(Math.min(value.length, 20));
|
|
231
|
+
|
|
232
|
+
return (
|
|
233
|
+
<span
|
|
234
|
+
className={cn(
|
|
235
|
+
'text-muted-foreground font-mono text-sm',
|
|
236
|
+
!showValues && 'select-none',
|
|
237
|
+
className,
|
|
238
|
+
)}
|
|
239
|
+
{...props}
|
|
240
|
+
>
|
|
241
|
+
{children ?? displayValue}
|
|
242
|
+
</span>
|
|
243
|
+
);
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
export type EnvironmentVariableCopyButtonProps = ComponentProps<
|
|
247
|
+
typeof Button
|
|
248
|
+
> & {
|
|
249
|
+
onCopy?: () => void;
|
|
250
|
+
onError?: (error: Error) => void;
|
|
251
|
+
timeout?: number;
|
|
252
|
+
copyFormat?: 'name' | 'value' | 'export';
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export const EnvironmentVariableCopyButton = ({
|
|
256
|
+
onCopy,
|
|
257
|
+
onError,
|
|
258
|
+
timeout = 2000,
|
|
259
|
+
copyFormat = 'value',
|
|
260
|
+
children,
|
|
261
|
+
className,
|
|
262
|
+
...props
|
|
263
|
+
}: EnvironmentVariableCopyButtonProps) => {
|
|
264
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
265
|
+
const timeoutRef = useRef<number>(0);
|
|
266
|
+
const { name, value } = useContext(EnvironmentVariableContext);
|
|
267
|
+
|
|
268
|
+
const getTextToCopy = useCallback((): string => {
|
|
269
|
+
const formatMap = {
|
|
270
|
+
export: () => `export ${name}="${value}"`,
|
|
271
|
+
name: () => name,
|
|
272
|
+
value: () => value,
|
|
273
|
+
};
|
|
274
|
+
return formatMap[copyFormat]();
|
|
275
|
+
}, [name, value, copyFormat]);
|
|
276
|
+
|
|
277
|
+
const copyToClipboard = useCallback(async () => {
|
|
278
|
+
if (typeof window === 'undefined' || !navigator?.clipboard?.writeText) {
|
|
279
|
+
onError?.(new Error('Clipboard API not available'));
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
try {
|
|
284
|
+
await navigator.clipboard.writeText(getTextToCopy());
|
|
285
|
+
setIsCopied(true);
|
|
286
|
+
onCopy?.();
|
|
287
|
+
timeoutRef.current = window.setTimeout(() => setIsCopied(false), timeout);
|
|
288
|
+
} catch (error) {
|
|
289
|
+
onError?.(error as Error);
|
|
290
|
+
}
|
|
291
|
+
}, [getTextToCopy, onCopy, onError, timeout]);
|
|
292
|
+
|
|
293
|
+
useEffect(
|
|
294
|
+
() => () => {
|
|
295
|
+
window.clearTimeout(timeoutRef.current);
|
|
296
|
+
},
|
|
297
|
+
[],
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
const Icon = isCopied ? CheckIcon : CopyIcon;
|
|
301
|
+
|
|
302
|
+
return (
|
|
303
|
+
<Button
|
|
304
|
+
className={cn('size-6 shrink-0', className)}
|
|
305
|
+
onClick={copyToClipboard}
|
|
306
|
+
size="icon"
|
|
307
|
+
variant="ghost"
|
|
308
|
+
{...props}
|
|
309
|
+
>
|
|
310
|
+
{children ?? <Icon size={12} />}
|
|
311
|
+
</Button>
|
|
312
|
+
);
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
export type EnvironmentVariableRequiredProps = ComponentProps<typeof Badge>;
|
|
316
|
+
|
|
317
|
+
export const EnvironmentVariableRequired = ({
|
|
318
|
+
className,
|
|
319
|
+
children,
|
|
320
|
+
...props
|
|
321
|
+
}: EnvironmentVariableRequiredProps) => (
|
|
322
|
+
<Badge className={cn('text-xs', className)} variant="secondary" {...props}>
|
|
323
|
+
{children ?? 'Required'}
|
|
324
|
+
</Badge>
|
|
325
|
+
);
|