Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

chore: remove deprecated plugin store code

Louis Beaumont9a09fbf7bac3
diff --git a/apps/screenpipe-app-tauri/components/onboarding/pipe-store.tsx b/apps/screenpipe-app-tauri/components/onboarding/pipe-store.tsx
deleted file mode 100644
index 60126fc06..000000000
--- a/apps/screenpipe-app-tauri/components/onboarding/pipe-store.tsx
+++ /dev/null
@@ -1,202 +0,0 @@
-import React from "react";
-import { Button } from "@/components/ui/button";
-import { Search, Loader2 } from "lucide-react";
-import OnboardingNavigation from "./navigation";
-import { toast } from "@/components/ui/use-toast";
-import { invoke } from "@tauri-apps/api/core";
-import posthog from "posthog-js";
-import { PipeApi } from "@/lib/api/store";
-import { useSettings } from "@/lib/hooks/use-settings";
-
-interface OnboardingPipeStoreProps {
- className?: string;
- handlePrevSlide: () => void;
- handleNextSlide: () => void;
-}
-
-const OnboardingPipeStore: React.FC<OnboardingPipeStoreProps> = ({
- className = "",
- handlePrevSlide,
- handleNextSlide,
-}) => {
- const [isLoading, setIsLoading] = React.useState(false);
- const [status, setStatus] = React.useState<string>("");
- const { settings } = useSettings();
- const handleOpenSearchPipe = async () => {
- setIsLoading(true);
- try {
- posthog.capture("open_search_pipe_from_onboarding");
-
- // Create initial toast
- const t = toast({
- title: "opening search pipe",
- description: "please wait...",
- duration: 5000,
- });
-
- // Check if screenpipe is running, if not spawn it
- try {
- await fetch("http://localhost:3030/health");
- } catch (error) {
- // Screenpipe not running, try to spawn it
- await invoke("stop_screenpipe");
- await new Promise((resolve) => setTimeout(resolve, 1_000));
- await invoke("spawn_screenpipe");
- await new Promise((resolve) => setTimeout(resolve, 5_000));
- }
-
- // First check if pipe is installed by listing pipes
- const listResponse = await fetch("http://localhost:3030/pipes/list");
- const listData = await listResponse.json();
- const searchPipe = listData.data.find(
- (p: any) => p.config?.id === "search"
- );
-
- // If not installed, download it first
- if (!searchPipe) {
- setStatus("downloading search pipe... (~10s)");
- const pipeApi = await PipeApi.create(settings.user?.token!);
- const storePlugins = await pipeApi.listStorePlugins();
- const downloadData = await pipeApi.downloadPipe(
- storePlugins.find((p) => p.name === "search")?.id!
- );
-
- await fetch("http://localhost:3030/pipes/download-private", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- pipe_name: "search",
- pipe_id: "search",
- url: downloadData.download_url,
- }),
- });
-
- // Wait for download to complete
- await new Promise((resolve) => setTimeout(resolve, 2000));
- }
-
- // Enable the search pipe
- setStatus("enabling search pipe... (~10s)");
- await fetch("http://localhost:3030/pipes/enable", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ pipe_id: "search" }),
- });
-
- // Wait for pipe to initialize
- setStatus("initializing search pipe... (~10s)");
- await new Promise((resolve) => setTimeout(resolve, 2000));
-
- // Get updated pipe info to find the port
- const response = await fetch("http://localhost:3030/pipes/list");
- const data = await response.json();
- const updatedSearchPipe = data.data.find(
- (p: any) => p.config?.id === "search"
- );
-
- if (!updatedSearchPipe?.config?.port) {
- throw new Error("search pipe not found or port not configured");
- }
-
- // Check if pipe is actually running
- try {
- await fetch(`http://localhost:${updatedSearchPipe.config.port}`, {
- mode: "no-cors",
- });
- } catch (error) {
- throw new Error("search pipe failed to start");
- }
-
- // Open the pipe window
- await invoke("open_pipe_window", {
- port: updatedSearchPipe.config.port,
- title: "search",
- });
-
- t.update({
- id: t.id,
- title: "search pipe ready",
- description: "you can now search through your recordings",
- duration: 2000,
- });
- } catch (error) {
- console.error("failed to open search pipe:", error);
- toast({
- title: "error opening search pipe",
- description: "please try again or check the logs",
- variant: "destructive",
- });
- } finally {
- setIsLoading(false);
- setStatus("");
- }
- };
-
- return (
- <div
- className={`${className} w-full h-screen flex flex-col px-6 overflow-y-auto`}
- >
- <div className="flex-1 flex flex-col items-center">
- <div className="flex flex-col items-center mb-8">
- <img className="w-24 h-24" src="/128x128.png" alt="screenpipe-logo" />
- <h1 className="text-2xl font-bold mt-4">welcome to the pipe store</h1>
- </div>
-
- <div className="space-y-8 max-w-2xl mx-auto w-full">
- {/* Store preview image */}
- <img
- src="/pipe-store-preview.png"
- alt="pipe store interface"
- className="w-full rounded-lg border shadow-sm"
- />
-
- <div className="space-y-4 text-center">
- <p className="text-muted-foreground my-2">
- screenpipe records your screen and audio 24/7 and makes it easy
- for AI to search through your recordings. developers can create
- powerful apps on top of screenpipe. let&apos;s start with
- &quot;search&quot; to explore your recordings. once in the search
- pipe, you can use the &quot;search&quot; button to search through
- your recordings and ask a summary to AI.
- </p>
-
- <div className="flex flex-col items-center">
- <Button
- size="lg"
- className="gap-2 my-8"
- onClick={handleOpenSearchPipe}
- disabled={isLoading}
- >
- {isLoading ? (
- <Loader2 className="w-4 h-4 animate-spin" />
- ) : (
- <Search className="w-4 h-4" />
- )}
- {isLoading ? "opening search..." : "open search pipe"}
- </Button>
- {status && (
- <p className="text-sm text-muted-foreground mt-1">{status}</p>
- )}
- </div>
- </div>
- </div>
- </div>
-
- <div className="my-8" />
-
- <OnboardingNavigation
- className="py-6"
- handlePrevSlide={handlePrevSlide}
- handleNextSlide={handleNextSlide}
- prevBtnText="previous"
- nextBtnText="end"
- />
- </div>
- );
-};
-
-export default OnboardingPipeStore;
diff --git a/apps/screenpipe-app-tauri/components/pipe-config-form.tsx b/apps/screenpipe-app-tauri/components/pipe-config-form.tsx
deleted file mode 100644
index d3870e6cc..000000000
--- a/apps/screenpipe-app-tauri/components/pipe-config-form.tsx
+++ /dev/null
@@ -1,517 +0,0 @@
-import React, { useState, useEffect } from "react";
-import { Input } from "./ui/input";
-import { Button } from "./ui/button";
-import { Label } from "./ui/label";
-import { Checkbox } from "./ui/checkbox";
-import { invoke } from "@tauri-apps/api/core";
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "./ui/tooltip";
-import { Layers, Layout, RefreshCw } from "lucide-react";
-import { toast } from "./ui/use-toast";
-import { InstalledPipe, PipeWithStatus } from "./pipe-store/types";
-import { SqlAutocompleteInput } from "./sql-autocomplete-input";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "./ui/select";
-import { HelpCircle } from "lucide-react";
-import { MemoizedReactMarkdown } from "./markdown";
-import { CodeBlock } from "./ui/codeblock";
-import remarkGfm from "remark-gfm";
-import remarkMath from "remark-math";
-import { open } from "@tauri-apps/plugin-dialog";
-import { FolderOpen } from "lucide-react";
-
-type PipeConfigFormProps = {
- pipe: PipeWithStatus;
- onConfigSave: (config: Record<string, any>) => void;
-};
-
-type FieldConfig = {
- name: string;
- type: string;
- default: any;
- description: string;
- value: any;
-};
-
-export const PipeConfigForm: React.FC<PipeConfigFormProps> = ({
- pipe,
- onConfigSave,
-}) => {
- const [config, setConfig] = useState(pipe.installed_config);
-
- useEffect(() => {
- setConfig(pipe.installed_config);
- }, [pipe]);
-
- const handleInputChange = (name: string, value: any) => {
- if (!config) return;
- setConfig((prevConfig) => {
- if (!prevConfig) return prevConfig;
- return {
- ...prevConfig,
- fields: prevConfig.fields?.map((field: FieldConfig) =>
- field.name === name ? { ...field, value } : field
- ),
- };
- });
- };
-
- const renderConfigInput = (field: FieldConfig) => {
- const value = field?.value ?? field?.default;
-
- const resetToDefault = () => {
- handleInputChange(field.name, field.default);
- };
-
- switch (field.type) {
- case "boolean":
- return (
- <div className="flex items-center space-x-2">
- <Checkbox
- id={field.name}
- checked={value}
- onCheckedChange={(checked) =>
- handleInputChange(field.name, checked)
- }
- />
- <Label htmlFor={field.name}>{field.name}</Label>
- </div>
- );
- case "number":
- return (
- <div className="flex items-center space-x-2">
- <Input
- id={field.name}
- type="number"
- value={value}
- onChange={(e) =>
- handleInputChange(field.name, parseFloat(e.target.value) || 0)
- }
- onWheel={(e) => e.preventDefault()} // prevent scrolling down breaking stuff
- step="any"
- autoCorrect="off"
- spellCheck="false"
- />
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="icon"
- variant="ghost"
- onClick={resetToDefault}
- className="h-8 w-8"
- >
- <RefreshCw className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Reset to default</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- );
- case "time":
- return (
- <div className="flex items-center space-x-2">
- <Input
- id={field.name}
- type="time"
- value={value}
- onChange={(e) => handleInputChange(field.name, e.target.value)}
- autoCorrect="off"
- spellCheck="false"
- />
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="icon"
- variant="ghost"
- onClick={resetToDefault}
- className="h-8 w-8"
- >
- <RefreshCw className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Reset to default</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- );
- case "window":
- return (
- <div className="flex items-center space-x-2 w-full">
- <SqlAutocompleteInput
- className="w-full"
- id={field.name}
- placeholder={`Enter ${field.name}`}
- value={value}
- onChange={(newValue) => handleInputChange(field.name, newValue)}
- type="window"
- icon={<Layout className="h-4 w-4" />}
- />
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="icon"
- variant="ghost"
- onClick={resetToDefault}
- className="h-8 w-8"
- >
- <RefreshCw className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Reset to default</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- );
- case "app":
- return (
- <div className="flex items-center space-x-2 w-full">
- <SqlAutocompleteInput
- className="w-full"
- id={field.name}
- placeholder={`Enter ${field.name}`}
- value={value}
- onChange={(newValue) => handleInputChange(field.name, newValue)}
- type="app"
- icon={<Layout className="h-4 w-4" />}
- />
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="icon"
- variant="ghost"
- onClick={resetToDefault}
- className="h-8 w-8"
- >
- <RefreshCw className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Reset to default</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- );
- case "contentType":
- return (
- <div className="space-y-2">
- <div className="flex items-center space-x-2">
- <Select
- value={value}
- onValueChange={(newValue) =>
- handleInputChange(field.name, newValue)
- }
- >
- <SelectTrigger id={field.name} className="relative w-full">
- <Layers
- className="absolute left-2 top-1/2 transform -translate-y-1/2 text-gray-400"
- size={18}
- />
- <SelectValue placeholder="content type" />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="all">
- <span className="pl-6">all</span>
- </SelectItem>
- <SelectItem value="ocr">
- <span className="pl-6">ocr</span>
- </SelectItem>
- <SelectItem value="audio">
- <span className="pl-6">audio</span>
- </SelectItem>
- </SelectContent>
- </Select>
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="icon"
- variant="ghost"
- onClick={resetToDefault}
- className="h-8 w-8"
- >
- <RefreshCw className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Reset to default</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- </div>
- );
- case "path":
- return (
- <div className="flex items-center space-x-2">
- <Input
- id={field.name}
- type="text"
- value={value}
- onChange={(e) => handleInputChange(field.name, e.target.value)}
- autoCorrect="off"
- spellCheck="false"
- />
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="icon"
- variant="ghost"
- onClick={async () => {
- try {
- const selectedPath = await open({
- directory: true,
- multiple: false,
- });
- if (selectedPath) {
- handleInputChange(field.name, selectedPath);
- }
- } catch (error) {
- console.error("failed to select path:", error);
- }
- }}
- className="h-8 w-8"
- >
- <FolderOpen className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Select folder</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="icon"
- variant="ghost"
- onClick={resetToDefault}
- className="h-8 w-8"
- >
- <RefreshCw className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Reset to default</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- );
- default:
- return (
- <div className="flex items-center space-x-2">
- <Input
- id={field.name}
- type="text"
- value={value}
- onChange={(e) => handleInputChange(field.name, e.target.value)}
- autoCorrect="off"
- spellCheck="false"
- />
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="icon"
- variant="ghost"
- onClick={resetToDefault}
- className="h-8 w-8"
- >
- <RefreshCw className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Reset to default</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- );
- }
- };
-
- return (
- <div className="space-y-6">
- <h3 className="text-lg font-semibold">pipe configuration</h3>
-
- <div className="space-y-2">
- <Label htmlFor="port" className="font-medium">
- port (number)
- </Label>
- <div className="flex items-center space-x-2">
- <Input
- id="port"
- type="number"
- value={config?.port ?? ""}
- onChange={(e) =>
- setConfig((prev) =>
- prev
- ? {
- ...prev,
- port: parseInt(e.target.value) || 3000,
- }
- : prev
- )
- }
- onWheel={(e) => e.preventDefault()}
- step="1"
- min="1"
- max="65535"
- autoCorrect="off"
- spellCheck="false"
- />
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="icon"
- variant="ghost"
- onClick={() =>
- setConfig((prev) => (prev ? { ...prev, port: 3000 } : prev))
- }
- className="h-8 w-8"
- >
- <RefreshCw className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Reset to default (3000)</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- <MemoizedReactMarkdown
- className="prose prose-sm break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 w-full"
- remarkPlugins={[remarkGfm, remarkMath]}
- components={{
- p({ children }) {
- return <p className="mb-2 last:mb-0">{children}</p>;
- },
- a({ node, href, children, ...props }) {
- return (
- <a
- href={href}
- target="_blank"
- rel="noopener noreferrer"
- {...props}
- >
- {children}
- </a>
- );
- },
- code({ node, className, children, ...props }) {
- const content = String(children).replace(/\n$/, "");
- const match = /language-(\w+)/.exec(className || "");
-
- if (!match) {
- return (
- <code
- className="px-1 py-0.5 rounded-sm font-mono text-sm"
- {...props}
- >
- {content}
- </code>
- );
- }
-
- return (
- <CodeBlock
- key={Math.random()}
- language={(match && match[1]) || ""}
- value={content}
- {...props}
- />
- );
- },
- }}
- >
- Port number for this pipe. If the selected port is already in use when
- starting the pipe, a random available port will be automatically
- assigned.
- </MemoizedReactMarkdown>
- </div>
-
- {config?.fields?.map((field: FieldConfig) => (
- <div key={field.name} className="space-y-2">
- <Label htmlFor={field.name} className="font-medium">
- {field.name} ({field.type})
- </Label>
- {renderConfigInput(field)}
- <MemoizedReactMarkdown
- className="prose prose-sm break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 w-full"
- remarkPlugins={[remarkGfm, remarkMath]}
- components={{
- p({ children }) {
- return <p className="mb-2 last:mb-0">{children}</p>;
- },
- a({ node, href, children, ...props }) {
- return (
- <a
- href={href}
- target="_blank"
- rel="noopener noreferrer"
- {...props}
- >
- {children}
- </a>
- );
- },
- code({ node, className, children, ...props }) {
- const content = String(children).replace(/\n$/, "");
- const match = /language-(\w+)/.exec(className || "");
-
- if (!match) {
- return (
- <code
- className="px-1 py-0.5 rounded-sm font-mono text-sm"
- {...props}
- >
- {content}
- </code>
- );
- }
-
- return (
- <CodeBlock
- key={Math.random()}
- language={(match && match[1]) || ""}
- value={content}
- {...props}
- />
- );
- },
- }}
- >
- {field.description}
- </MemoizedReactMarkdown>
- </div>
- ))}
- <Button type="submit" onClick={() => onConfigSave(config || {})}>
- save configuration
- </Button>
- </div>
- );
-};
diff --git a/apps/screenpipe-app-tauri/components/pipe-store-markdown.tsx b/apps/screenpipe-app-tauri/components/pipe-store-markdown.tsx
deleted file mode 100644
index 4b02e8ad4..000000000
--- a/apps/screenpipe-app-tauri/components/pipe-store-markdown.tsx
+++ /dev/null
@@ -1,169 +0,0 @@
-import { MemoizedReactMarkdown } from "@/components/markdown";
-import { CodeBlock } from "@/components/ui/codeblock";
-import { useState } from "react";
-import remarkGfm from "remark-gfm";
-import remarkMath from "remark-math";
-import { useCopyToClipboard } from "@/lib/hooks/use-copy-to-clipboard";
-import { Button } from "@/components/ui/button";
-import { Copy, Check } from "lucide-react";
-import { convertHtmlToMarkdown } from "@/lib/utils";
-
-interface MarkdownProps {
- content: string;
- className?: string;
- variant?: "default" | "compact";
-}
-
-export function PipeStoreMarkdown({
- content,
- className,
- variant = "default",
-}: MarkdownProps) {
- const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 });
- const processedContent = convertHtmlToMarkdown(content);
-
- return (
- <div className={`prose prose-sm dark:prose-invert max-w-none ${className}`}>
- <MemoizedReactMarkdown
- remarkPlugins={[remarkGfm, remarkMath]}
- components={{
- p({ children }) {
- return <span className="mb-2 last:mb-0">{children}</span>;
- },
- code({ node, className, children, ...props }) {
- const content = String(children).replace(/\n$/, "");
- const match = /language-(\w+)/.exec(className || "");
-
- return match ? (
- <CodeBlock
- key={Math.random()}
- language={(match && match[1]) || ""}
- value={content}
- {...props}
- />
- ) : (
- <code
- className="relative group py-0.5 px-1 rounded-sm font-mono text-sm text-grey-900 inline-block"
- {...props}
- >
- {content}
- <Button
- size="icon"
- variant="ghost"
- className="absolute -right-3 -top-3 opacity-0 group-hover:opacity-100 transition-opacity h-6 w-6"
- onClick={() => copyToClipboard(content)}
- >
- {isCopied ? (
- <Check className="h-3 w-3" />
- ) : (
- <Copy className="h-3 w-3" />
- )}
- </Button>
- </code>
- );
- },
- a({ href, children }) {
- const isDirectVideo =
- href?.match(/\.(mp4|webm|ogg)$/) ||
- href?.includes("user-attachments/assets");
- const youtubeMatch = href?.match(
- /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/
- );
-
- if (isDirectVideo || youtubeMatch) {
- return (
- <span className="block">
- {isDirectVideo ? (
- <RetryableVideo
- src={href}
- maxRetries={3}
- retryDelay={1000}
- />
- ) : (
- <iframe
- width="100%"
- height="315"
- src={`https://www.youtube.com/embed/${youtubeMatch![1]}`}
- frameBorder="0"
- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
- allowFullScreen
- className="max-w-full"
- style={{ maxHeight: "400px" }}
- />
- )}
- </span>
- );
- }
-
- return (
- <a href={href} target="_blank" rel="noopener noreferrer">
- {children}
- </a>
- );
- },
- img({ node, ...props }) {
- return (
- <img
- {...props}
- className="max-w-full h-auto rounded-lg"
- style={{ maxHeight: "600px" }}
- />
- );
- },
- }}
- >
- {processedContent.replace(/Â/g, "")}
- </MemoizedReactMarkdown>
- </div>
- );
-}
-
-const RetryableVideo = ({
- src,
- maxRetries = 3,
- retryDelay = 1000,
-}: {
- src?: string;
- maxRetries?: number;
- retryDelay?: number;
-}) => {
- const [retries, setRetries] = useState(0);
- const [key, setKey] = useState(0);
- const [isLoading, setIsLoading] = useState(true);
-
- const handleError = (e: any) => {
- console.error("video loading error:", e);
- if (retries < maxRetries) {
- setTimeout(() => {
- setRetries(retries + 1);
- setKey(key + 1);
- }, retryDelay);
- }
- };
-
- return (
- <div className="relative">
- {isLoading && (
- <div className="absolute inset-0 animate-pulse bg-zinc-800 rounded-md" />
- )}
- <video
- key={key}
- src={src}
- controls
- className="max-w-full h-auto"
- style={{ maxHeight: "400px" }}
- onError={handleError}
- onLoadStart={() => {
- console.log("video load started:", src);
- setIsLoading(true);
- }}
- onLoadedData={() => {
- console.log("video data loaded:", src);
- setIsLoading(false);
- }}
- >
- your browser does not support the video tag.
- </video>
- </div>
- );
-};
diff --git a/apps/screenpipe-app-tauri/components/pipe-store/add-pipe-form.tsx b/apps/screenpipe-app-tauri/components/pipe-store/add-pipe-form.tsx
deleted file mode 100644
index c15672c34..000000000
--- a/apps/screenpipe-app-tauri/components/pipe-store/add-pipe-form.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-import React, { useState } from "react";
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Plus, FolderOpen, Puzzle } from "lucide-react";
-import { open } from "@tauri-apps/plugin-dialog";
-import { PublishDialog } from "../publish-dialog";
-import { PipeStorePlugin } from "@/lib/api/store";
-
-interface AddPipeFormProps {
- onAddPipe: (url: string) => Promise<any>;
- onLoadFromLocalFolder: (setNewRepoUrl: (url: string) => void) => Promise<any>;
- isHealthy: boolean;
-}
-
-export const AddPipeForm: React.FC<AddPipeFormProps> = ({
- onAddPipe,
- onLoadFromLocalFolder,
- isHealthy,
-}) => {
- const [newRepoUrl, setNewRepoUrl] = useState("");
-
- return (
- <div className="border rounded-lg p-4 space-y-3 md:w-[50%] w-full mx-auto">
- <div className="flex gap-2">
- <div className="flex-1 relative">
- <Input
- type="url"
- placeholder={
- !isHealthy
- ? "screenpipe not running..."
- : "enter github url or local path"
- }
- value={newRepoUrl}
- onChange={(e) => setNewRepoUrl(e.target.value)}
- autoCorrect="off"
- autoComplete="off"
- disabled={!isHealthy}
- />
- </div>
- <Button
- onClick={() => onAddPipe(newRepoUrl)}
- disabled={!newRepoUrl || !isHealthy}
- size="icon"
- className="h-10 w-10"
- >
- <Plus className="h-4 w-4" />
- </Button>
- <Button
- onClick={() => onLoadFromLocalFolder(setNewRepoUrl)}
- variant="outline"
- size="icon"
- className="h-10 w-10"
- disabled={!isHealthy}
- >
- <FolderOpen className="h-4 w-4" />
- </Button>
- </div>
- <div className="text-sm text-muted-foreground">
- <a
- href="https://docs.screenpi.pe/plugins"
- target="_blank"
- rel="noopener noreferrer"
- className="hover:underline flex items-center gap-1"
- >
- <Puzzle className="h-3 w-3" />
- learn how to create your own pipe
- </a>
- </div>
- </div>
- );
-};
diff --git a/apps/screenpipe-app-tauri/components/pipe-store/pipe-card.tsx b/apps/screenpipe-app-tauri/components/pipe-store/pipe-card.tsx
deleted file mode 100644
index b6f43d5e5..000000000
--- a/apps/screenpipe-app-tauri/components/pipe-store/pipe-card.tsx
+++ /dev/null
@@ -1,425 +0,0 @@
-import React, { useCallback, useEffect, useState } from "react";
-import { Button } from "@/components/ui/button";
-import {
- Download,
- Puzzle,
- UserIcon,
- Loader2,
- Power,
- ArrowUpCircle,
- AlertCircle,
-} from "lucide-react";
-import { PipeStoreMarkdown } from "@/components/pipe-store-markdown";
-import { BuildStatus, PipeWithStatus } from "./types";
-import { invoke } from "@tauri-apps/api/core";
-import { toast } from "@/components/ui/use-toast";
-import { motion } from "framer-motion";
-import posthog from "posthog-js";
-import { useSettings } from "@/lib/hooks/use-settings";
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "@/components/ui/tooltip";
-
-interface PipeCardProps {
- pipe: PipeWithStatus;
- onInstall: (pipe: PipeWithStatus, onComplete: () => void) => Promise<any>;
- onPurchase: (pipe: PipeWithStatus, onComplete: () => void) => Promise<any>;
- onClick: (pipe: PipeWithStatus) => void;
- isLoadingPurchase?: boolean;
- isLoadingInstall?: boolean;
- onToggle: (pipe: PipeWithStatus, onComplete: () => void) => Promise<any>;
- setPipe: (pipe: PipeWithStatus) => void;
-}
-
-export function getBuildStatus(status: BuildStatus | undefined): string {
- return typeof status === "object" ? status.status : status || "";
-}
-
-function getBuildStepMessage(buildStatus: BuildStatus | undefined): string {
- if (typeof buildStatus !== "object") return "building...";
-
- const { step, status } = buildStatus;
- if (status === "not_started") {
- return "waiting to start...";
- }
-
- switch (step) {
- case "downloading":
- return "downloading files...";
- case "extracting":
- return "extracting files...";
- case "installing":
- return "installing dependencies...";
- case "completed":
- return "completed installation";
- case "building":
- return "building application...";
- default:
- return step || "processing...";
- }
-}
-
-function stripMarkdown(text: string): string {
- if (!text) return "";
- return text
- .replace(/<\/?[^>]+(>|$)/g, "") // Remove HTML tags
- .replace(/\*\*(.*?)\*\*|__(.*?)__/g, "$1$2") // Bold
- .replace(/\*(.*?)\*|_(.*?)_/g, "$1$2") // Italic
- .replace(/\[([^\]]+)\]\(([^)]+)\)/g, "$1") // Links
- .replace(/!\[([^\]]+)\]\(([^)]+)\)/g, "$1") // Images
- .replace(/#{1,6}\s+/g, "") // Headers
- .replace(/`{1,3}(.*?)`{1,3}/gs, "$1") // Code blocks
- .replace(/^\s*>[>\s]*/gm, "") // Blockquotes
- .replace(/^\s*[-*+]\s+/gm, "") // Unordered lists
- .replace(/^\s*\d+\.\s+/gm, "") // Ordered lists
- .replace(/~~(.*?)~~/g, "$1"); // Strikethrough
-}
-
-export const PipeCard: React.FC<PipeCardProps> = ({
- pipe,
- onInstall,
- onClick,
- onPurchase,
- setPipe,
- isLoadingPurchase,
- isLoadingInstall,
- onToggle,
-}) => {
- const [isLoading, setIsLoading] = useState(false);
- const { settings } = useSettings();
-
- const handleOpenWindow = async (e: React.MouseEvent) => {
- e.stopPropagation();
- try {
- if (pipe.installed_config?.port) {
- await invoke("open_pipe_window", {
- port: pipe.installed_config.port,
- title: pipe.name,
- });
- }
- } catch (err) {
- console.error("failed to open pipe window:", err);
- toast({
- title: "error opening pipe window",
- description: "please try again or check the logs",
- variant: "destructive",
- });
- }
- };
-
- useEffect(() => {
- const pollBuildStatus = async () => {
- const id = pipe.is_local ? pipe.id : pipe.name;
- try {
- const response = await fetch(
- `http://localhost:3030/pipes/build-status/${id}`
- );
-
- if (!response.ok) {
- throw new Error(`HTTP error! status: ${response.status}`);
- }
-
- const data = await response.json();
- console.log(data, pipe.installed_config?.buildStatus);
- if (
- data.buildStatus?.length > 0 &&
- JSON.stringify(data.buildStatus) !==
- JSON.stringify(pipe.installed_config?.buildStatus)
- ) {
- setPipe({
- ...pipe,
- installed_config: {
- ...pipe.installed_config,
- is_nextjs: pipe.installed_config?.is_nextjs ?? false,
- source: pipe.installed_config?.source ?? "",
- buildStatus: data.buildStatus as BuildStatus,
- },
- });
- }
- } catch (error) {
- console.error("Error polling build status:", error);
- setPipe({
- ...pipe,
- installed_config: {
- ...pipe.installed_config,
- is_nextjs: pipe.installed_config?.is_nextjs ?? false,
- source: pipe.installed_config?.source ?? "",
- buildStatus: {
- status: "error",
- step: "failed",
- error:
- error instanceof Error
- ? error.message
- : "Unknown error occurred",
- } as BuildStatus,
- },
- });
- }
- };
-
- let buildStatusInterval: NodeJS.Timeout | null = null;
- const buildStatus = pipe.installed_config?.buildStatus;
-
- const isUpdating =
- buildStatus === "updating" ||
- (typeof buildStatus === "object" && buildStatus.status === "updating");
-
- if (isUpdating) {
- return;
- }
-
- const isInProgress =
- buildStatus === "in_progress" ||
- (typeof buildStatus === "object" && buildStatus.status === "in_progress");
-
- if (isInProgress) {
- buildStatusInterval = setInterval(pollBuildStatus, 3000);
- }
-
- return () => {
- if (buildStatusInterval) {
- clearInterval(buildStatusInterval);
- }
- };
- }, [pipe.installed_config?.buildStatus]);
-
- const renderInstallationStatus = useCallback(() => {
- const buildStatus = pipe.installed_config?.buildStatus;
- const status = getBuildStatus(buildStatus);
-
- if (status === "updating") {
- return (
- <Button
- size="sm"
- variant="outline"
- disabled
- className="hover:bg-muted font-medium relative hover:!bg-muted no-card-hover"
- >
- <Loader2 className="h-3.5 w-3.5 mr-2 animate-spin" />
- <div className="flex flex-col items-start">
- <span>updating...</span>
- </div>
- </Button>
- );
- }
-
- if (status === "not_started" || status === "in_progress") {
- return (
- <Button
- size="sm"
- variant="outline"
- disabled
- className="hover:bg-muted font-medium relative hover:!bg-muted no-card-hover"
- >
- <Loader2 className="h-3.5 w-3.5 mr-2 animate-spin" />
- <div className="flex flex-col items-start">
- <span>{getBuildStepMessage(buildStatus)}</span>
- </div>
- </Button>
- );
- }
-
- if (status === "error") {
- return (
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="destructive"
- onClick={(e) => {
- e.stopPropagation();
- setIsLoading(true);
- onToggle(pipe, () => setIsLoading(false));
- }}
- className="font-medium no-card-hover"
- disabled={isLoading}
- >
- <AlertCircle className="h-3.5 w-3.5 mr-2" />
- retry
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- {typeof buildStatus === "object" && buildStatus.error
- ? buildStatus.error
- : "Installation failed"}
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- );
- }
-
- if (!pipe.is_enabled && buildStatus === "success") {
- return (
- <Button
- size="sm"
- variant="outline"
- onClick={(e) => {
- e.stopPropagation();
- setIsLoading(true);
- onToggle(pipe, () => setIsLoading(false));
- }}
- className="hover:bg-muted font-medium relative hover:!bg-muted no-card-hover"
- disabled={isLoading}
- >
- <Power className="h-3.5 w-3.5 mr-2" />
- enable
- </Button>
- );
- }
-
- return (
- <Button
- size="sm"
- variant="outline"
- onClick={handleOpenWindow}
- className="hover:bg-muted font-medium relative no-card-hover"
- >
- <Puzzle className="h-3.5 w-3.5 mr-2" />
- open
- </Button>
- );
- }, [pipe.installed_config?.buildStatus]);
-
- return (
- <motion.div
- className="group border rounded-xl p-5 hover:bg-muted/40 has-[.no-card-hover:hover]:hover:bg-transparent transition-all duration-200 cursor-pointer bg-card relative"
- onClick={() => onClick(pipe)}
- initial={{ opacity: 0, scale: 0.95 }}
- animate={{ opacity: 1, scale: 1 }}
- whileHover={{
- boxShadow: "0 0 10px rgba(255,255,255,0.1)",
- transition: { duration: 0.2 },
- }}
- >
- <div className="flex flex-col h-full justify-between space-y-4">
- <div className="flex items-start justify-between gap-4">
- <div className="flex items-center gap-3">
- <div className="flex-1 min-w-0">
- <h3 className="font-semibold text-lg tracking-tight">
- {pipe.name}
- </h3>
- <div className="text-sm text-muted-foreground">
- <PipeStoreMarkdown
- content={
- (pipe.description
- ? stripMarkdown(pipe.description).substring(0, 90)
- : "") + "..."
- }
- variant="compact"
- />
- </div>
- </div>
- </div>
- <div className="flex items-center gap-2 isolate">
- {pipe.is_installed ? (
- renderInstallationStatus()
- ) : (
- <Button
- size="sm"
- variant={pipe.is_paid ? "default" : "outline"}
- onClick={(e) => {
- e.stopPropagation();
- if (pipe.is_paid && !pipe.has_purchased) {
- setIsLoading(true);
- onPurchase(pipe, () => setIsLoading(false));
- posthog.capture("pipe_purchase", {
- pipe_id: pipe.id,
- email: settings.user?.email,
- });
- } else {
- setIsLoading(true);
- onInstall(pipe, () => setIsLoading(false));
- posthog.capture("pipe_install", {
- pipe_id: pipe.id,
- email: settings.user?.email,
- });
- }
- }}
- className="font-medium no-card-hover"
- disabled={isLoadingPurchase}
- >
- {isLoadingPurchase ? (
- <Loader2 className="mr-2 h-4 w-4 animate-spin" />
- ) : pipe.is_paid && !pipe.has_purchased ? (
- `$${pipe.price}`
- ) : (
- <>
- <Download className="h-3.5 w-3.5 mr-2" />
- get
- </>
- )}
- </Button>
- )}
- </div>
- </div>
- {pipe.developer_accounts.developer_name && (
- <div className="flex items-center gap-3 text-xs text-muted-foreground mt-auto">
- <div className="flex items-center gap-1">
- <div className="size-6 rounded-full bg-muted flex items-center justify-center">
- <UserIcon className="size-3" />
- </div>
- {pipe.developer_accounts.developer_name}
- </div>
- {pipe.plugin_analytics.downloads_count != null && (
- <span className="flex items-center gap-1">
- <Download className="h-3 w-3" />
- {pipe.plugin_analytics.downloads_count}
- </span>
- )}
- {pipe.source_code && (
- <motion.a
- href={pipe.source_code}
- target="_blank"
- rel="noopener noreferrer"
- onClick={(e) => e.stopPropagation()}
- className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-muted hover:bg-accent hover:text-accent-foreground transition-all duration-200 no-card-hover relative overflow-hidden"
- whileHover={{
- scale: 1.05,
- transition: {
- type: "spring",
- stiffness: 400,
- damping: 10,
- },
- }}
- whileTap={{ scale: 0.95 }}
- >
- <motion.div
- className="absolute inset-0 bg-gradient-to-r from-transparent via-white/10 to-transparent"
- initial={{ x: "-100%" }}
- whileHover={{
- x: "100%",
- transition: {
- duration: 0.6,
- ease: "easeInOut",
- },
- }}
- />
- <Download className="h-3 w-3" />
- <span className="relative z-10 font-mono">source</span>
- </motion.a>
- )}
- {pipe.is_local && (
- <span className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-muted font-mono text-xs">
- local
- </span>
- )}
- <span className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-white/5 font-mono text-xs">
- {pipe.installed_config?.version && "v"}
- {pipe.installed_config?.version}
- </span>
- {pipe.has_update && (
- <span className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-white/10 font-mono text-xs animate-pulse">
- <ArrowUpCircle className="h-3 w-3" />
- update
- </span>
- )}
- </div>
- )}
- </div>
- </motion.div>
- );
-};
diff --git a/apps/screenpipe-app-tauri/components/pipe-store/pipe-details.tsx b/apps/screenpipe-app-tauri/components/pipe-store/pipe-details.tsx
deleted file mode 100644
index 4caf77c06..000000000
--- a/apps/screenpipe-app-tauri/components/pipe-store/pipe-details.tsx
+++ /dev/null
@@ -1,331 +0,0 @@
-import React, { useState } from "react";
-import { Button } from "@/components/ui/button";
-import {
- ExternalLink,
- Power,
- Puzzle,
- RefreshCw,
- Trash2,
- X,
- Download,
- Loader2,
-} from "lucide-react";
-import { PipeStoreMarkdown } from "@/components/pipe-store-markdown";
-import { PipeWithStatus } from "./types";
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "../ui/tooltip";
-import { LogFileButton } from "../log-file-button";
-import { toast } from "../ui/use-toast";
-import { invoke } from "@tauri-apps/api/core";
-import { PipeConfigForm } from "../pipe-config-form";
-import { open as openUrl } from "@tauri-apps/plugin-shell";
-import { Badge } from "../ui/badge";
-import { getBuildStatus } from "./pipe-card";
-
-interface PipeDetailsProps {
- pipe: PipeWithStatus;
- onClose: () => void;
- onToggle: (pipe: PipeWithStatus, onComplete: () => void) => void;
- onConfigSave: (config: Record<string, any>, onComplete: () => void) => void;
- onUpdate: (pipe: PipeWithStatus, onComplete: () => void) => void;
- onDelete: (pipe: PipeWithStatus, onComplete: () => void) => void;
- onRefreshFromDisk: (pipe: PipeWithStatus, onComplete: () => void) => void;
- onInstall: (pipe: PipeWithStatus, onComplete: () => void) => void;
- onPurchase: (pipe: PipeWithStatus, onComplete: () => void) => void;
- isLoadingPurchase?: boolean;
- isLoadingInstall?: boolean;
-}
-
-const buildStatusNotAllows = ["in_progress", "not_started"];
-
-const isValidSource = (source?: string): boolean => {
- if (!source) return false;
-
- // github url pattern
- const githubPattern = /^https?:\/\/(?:www\.)?github\.com\/.+\/.+/i;
-
- // filesystem path patterns (unix and windows)
- const unixPattern = /^(?:\/|~\/)/;
- const windowsPattern = /^[a-zA-Z]:\\|^\\\\/;
-
- return (
- githubPattern.test(source) ||
- unixPattern.test(source) ||
- windowsPattern.test(source)
- );
-};
-
-export const PipeDetails: React.FC<PipeDetailsProps> = ({
- pipe,
- onClose,
- onToggle,
- onConfigSave,
- onUpdate,
- onDelete,
- onRefreshFromDisk,
- onInstall,
- onPurchase,
- isLoadingPurchase,
- isLoadingInstall,
-}) => {
- const [isLoading, setIsLoading] = useState(false);
- return (
- <div className="fixed inset-0 bg-background transform transition-transform duration-200 ease-in-out flex flex-col">
- <div className="flex items-center justify-between p-4 border-b bg-muted/30 flex-shrink-0">
- <div className="flex items-center gap-3">
- <Button
- variant="ghost"
- size="sm"
- onClick={onClose}
- className="hover:bg-muted"
- >
- <X className="h-4 w-4" />
- </Button>
- <h2 className="text-lg font-medium">{pipe.name}</h2>
- <Badge variant={"outline"} className="font-mono text-xs">
- by {pipe.developer_accounts.developer_name}
- </Badge>
- {pipe.has_update && (
- <Badge
- variant="default"
- className="bg-gray-800 text-xs animate-pulse"
- >
- update available
- </Badge>
- )}
- </div>
- </div>
-
- <div className="flex-1 flex overflow-hidden">
- {pipe.is_installed && (
- <div className="w-[320px] border-r bg-muted/10 flex-shrink-0 overflow-y-auto">
- <div className="p-4 space-y-4">
- <div className="flex gap-2">
- <div className="flex flex-col gap-1">
- <div className="flex items-center gap-2">
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- onClick={() => {
- setIsLoading(true);
- onToggle(pipe, () => setIsLoading(false));
- }}
- variant={
- pipe.installed_config?.enabled
- ? "default"
- : "outline"
- }
- size="icon"
- className="h-8 w-8"
- >
- <Power className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {pipe.installed_config?.enabled
- ? "disable"
- : "enable"}{" "}
- pipe
- </p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
-
- <LogFileButton className="text-xs" />
-
- {pipe.installed_config?.source &&
- isValidSource(pipe.installed_config.source) ? (
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- onClick={() =>
- onRefreshFromDisk(pipe, () =>
- setIsLoading(false)
- )
- }
- variant="outline"
- size="icon"
- className="h-8 w-8"
- >
- <RefreshCw className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>refresh the code from your local disk</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- ) : (
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- onClick={() => {
- onUpdate(pipe, () => setIsLoading(false));
- }}
- variant="outline"
- size="icon"
- className="h-8 w-8"
- >
- <RefreshCw className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- {pipe.has_update ? (
- <p>update available! click to update pipe</p>
- ) : (
- <p>check for updates</p>
- )}
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- )}
-
- <div className="flex items-center gap-2">
- {/* Only show delete button for non-core pipes */}
- {!pipe.is_core_pipe && (
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- onClick={() => {
- onDelete(pipe, () => setIsLoading(false));
- }}
- variant="outline"
- size="icon"
- className="h-8 w-8"
- >
- <Trash2 className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>delete pipe</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- )}
- </div>
- </div>
- </div>
- </div>
-
- {pipe.installed_config?.enabled && (
- <div className="space-y-3 pt-4 border-t">
- <PipeConfigForm
- pipe={pipe}
- onConfigSave={(config) => {
- onConfigSave(config, () => setIsLoading(false));
- }}
- />
- </div>
- )}
- </div>
- </div>
- )}
-
- <main className="flex-1 overflow-y-auto">
- <div className="max-w-3xl mx-auto p-8 ">
- {!pipe.is_installed && (
- <div className="mb-6">
- <Button
- size="sm"
- variant={pipe.is_paid ? "default" : "outline"}
- onClick={() => {
- if (pipe.is_paid && !pipe.has_purchased) {
- setIsLoading(true);
- onPurchase(pipe, () => setIsLoading(false));
- } else {
- setIsLoading(true);
- onInstall(pipe, () => setIsLoading(false));
- }
- }}
- className="font-medium"
- disabled={isLoadingPurchase || isLoadingInstall}
- >
- {isLoadingPurchase ? (
- <Loader2 className="mr-2 h-4 w-4 animate-spin" />
- ) : isLoadingInstall ? (
- <>
- <Loader2 className="mr-2 h-4 w-4 animate-spin" />
- installing...
- </>
- ) : pipe.is_paid && !pipe.has_purchased ? (
- `$${pipe.price}`
- ) : (
- <>
- <Download className="h-3.5 w-3.5 mr-2" />
- get
- </>
- )}
- </Button>
- </div>
- )}
-
- {pipe.installed_config?.enabled &&
- !buildStatusNotAllows.includes(
- getBuildStatus(pipe.installed_config.buildStatus) ?? ""
- ) &&
- pipe.installed_config?.port && (
- <div>
- <div className="flex justify-between items-center mb-4">
- <div className="flex gap-2">
- <Button
- variant="outline"
- onClick={() =>
- openUrl(
- `http://localhost:${pipe.installed_config?.port}`
- )
- }
- disabled={!pipe.installed_config?.enabled}
- >
- <ExternalLink className="mr-2 h-3.5 w-3.5" />
- open in browser
- </Button>
- <Button
- variant="default"
- onClick={async () => {
- try {
- await invoke("open_pipe_window", {
- port: pipe.installed_config!.port,
- title: pipe.name,
- });
- } catch (err) {
- console.error("failed to open pipe window:", err);
- toast({
- title: "error opening pipe window",
- description: "please try again or check the logs",
- variant: "destructive",
- });
- }
- }}
- disabled={!pipe.installed_config.enabled}
- >
- <Puzzle className="mr-2 h-3.5 w-3.5" />
- open as app
- </Button>
- </div>
- </div>
- </div>
- )}
-
- {pipe.description && (
- <div>
- <h3 className="text-lg font-medium mb-4">about this pipe</h3>
- <div className="prose prose-sm dark:prose-invert max-w-none">
- <PipeStoreMarkdown content={pipe.description} />
- </div>
- </div>
- )}
- </div>
- </main>
- </div>
- </div>
- );
-};
diff --git a/apps/screenpipe-app-tauri/components/pipe-store/types.ts b/apps/screenpipe-app-tauri/components/pipe-store/types.ts
deleted file mode 100644
index 265ab8fda..000000000
--- a/apps/screenpipe-app-tauri/components/pipe-store/types.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-import { PipeStorePlugin } from "@/lib/api/store";
-
-export type BuildStatus =
- | string
- | {
- status: "in_progress" | "error" | "success" | "not_started" | "updating";
- step: string;
- progress?: number;
- error?: string;
- };
-
-export interface InstalledConfig {
- port?: number;
- enabled?: boolean;
- version?: string;
- buildStatus?: BuildStatus;
- is_nextjs?: boolean;
- source?: string;
-}
-
-export interface InstalledPipe {
- config: InstalledConfig & {
- id?: string;
- enabled?: boolean;
- is_nextjs: boolean;
- port?: number;
- source: string;
- crons?: {
- path: string;
- schedule: string;
- }[];
- fields?: Record<string, any>;
- version?: string;
- };
- desc: string;
- id: string;
-}
-
-export interface PipeWithStatus extends PipeStorePlugin {
- is_installed: boolean;
- is_enabled: boolean;
- installed_config?: InstalledPipe["config"];
- has_purchased: boolean;
- is_core_pipe: boolean;
- is_installing?: boolean;
- has_update?: boolean;
- is_local?: boolean;
-}
-
-export interface BrokenPipe {
- id: string;
- lastAttempt: number;
-}
diff --git a/apps/screenpipe-app-tauri/components/publish-dialog.tsx b/apps/screenpipe-app-tauri/components/publish-dialog.tsx
deleted file mode 100644
index cee1ab862..000000000
--- a/apps/screenpipe-app-tauri/components/publish-dialog.tsx
+++ /dev/null
@@ -1,226 +0,0 @@
-import React, { useState } from "react";
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Label } from "@/components/ui/label";
-import { Textarea } from "@/components/ui/textarea";
-import { Plus, Upload, ExternalLink } from "lucide-react";
-import { toast } from "./ui/use-toast";
-import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogFooter,
- DialogHeader,
- DialogTitle,
-} from "@/components/ui/dialog";
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "@/components/ui/tooltip";
-import { open as openUrl } from "@tauri-apps/plugin-shell";
-import { PipeWithStatus } from "./pipe-store/types";
-
-interface PublishDialogProps {
- app: PipeWithStatus | null;
-}
-
-export const PublishDialog: React.FC<PublishDialogProps> = ({ app }) => {
- const [open, setOpen] = useState(false);
- const [name, setName] = useState(app?.id || "");
- const [description, setDescription] = useState("");
- const [githubUrl, setGithubUrl] = useState("");
- const [price, setPrice] = useState("0");
- const [isSubmitting, setIsSubmitting] = useState(false);
- const [githubUsername, setGithubUsername] = useState("");
- const [issueUrl, setIssueUrl] = useState<string | null>(null);
-
- const handleSubmit = async () => {
- try {
- setIsSubmitting(true);
-
- const host = "https://screenpi.pe";
- // const host = "http://localhost:3001";
-
- const response = await fetch(`${host}/api/publish`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- name,
- description,
- githubUrl,
- price: parseFloat(price),
- githubUsername,
- }),
- });
-
- const data = await response.json();
- if (!response.ok) throw new Error("failed to publish");
-
- setIssueUrl(data.issueUrl);
- toast({
- title: "submission received",
- description: "we'll review your app and add it to the store soon",
- });
- } catch (error) {
- console.error("failed to publish:", error);
- toast({
- title: "error publishing app",
- description: "please try again later",
- variant: "destructive",
- });
- } finally {
- setIsSubmitting(false);
- }
- };
-
- return (
- <>
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- onClick={() => setOpen(true)}
- variant="outline"
- size="icon"
- className="h-10 w-10"
- >
- <Upload className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>publish to store</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
-
- <Dialog open={open} onOpenChange={setOpen}>
- <DialogContent className="sm:max-w-[425px]">
- <DialogHeader>
- <DialogTitle>publish to store</DialogTitle>
- <DialogDescription>
- submit your app to the screenpipe community store
- </DialogDescription>
- </DialogHeader>
-
- {issueUrl ? (
- <div className="py-6 space-y-4">
- <div className="text-center space-y-2">
- <div className="text-lg font-medium">
- submission successful!
- </div>
- <p className="text-sm text-muted-foreground">
- your app has been submitted for review
- </p>
- </div>
- <Button className="w-full" onClick={() => openUrl(issueUrl)}>
- <ExternalLink className="mr-2 h-4 w-4" />
- view submission status
- </Button>
- <Button
- variant="outline"
- className="w-full"
- onClick={() => {
- setOpen(false);
- setIssueUrl(null);
- // Reset other form fields
- setName("");
- setDescription("");
- setGithubUrl("");
- setGithubUsername("");
- }}
- >
- close
- </Button>
- </div>
- ) : (
- <>
- <div className="grid gap-4 py-4">
- <div className="grid gap-2">
- <Label htmlFor="name">name</Label>
- <Input
- id="name"
- value={name}
- onChange={(e) => setName(e.target.value)}
- placeholder="my-awesome-app"
- autoCorrect="off"
- autoComplete="off"
- />
- </div>
- <div className="grid gap-2">
- <Label htmlFor="description">description</Label>
- <Textarea
- id="description"
- value={description}
- onChange={(e) => setDescription(e.target.value)}
- placeholder="what does your app do?"
- />
- </div>
- <div className="grid gap-2">
- <Label htmlFor="github">github repository url</Label>
- <div className="flex gap-2">
- <Input
- id="github"
- value={githubUrl}
- onChange={(e) => setGithubUrl(e.target.value)}
- placeholder="https://github.com/username/repo"
- autoCorrect="off"
- autoComplete="off"
- />
- <Button
- variant="outline"
- onClick={() => openUrl("https://github.com/new")}
- size="icon"
- >
- <Plus className="h-4 w-4" />
- </Button>
- </div>
- </div>
- <div className="grid gap-2">
- <Label htmlFor="price">price (soon)</Label>
- <Input
- id="price"
- type="number"
- value={price}
- onChange={(e) => setPrice(e.target.value)}
- disabled
- min="0"
- step="0.01"
- />
- </div>
- <div className="grid gap-2">
- <Label htmlFor="github-username">github username</Label>
- <Input
- id="github-username"
- value={githubUsername}
- onChange={(e) => setGithubUsername(e.target.value)}
- placeholder="your github username"
- autoCorrect="off"
- autoComplete="off"
- />
- </div>
- </div>
- <DialogFooter>
- <Button
- onClick={handleSubmit}
- disabled={
- !name ||
- !description ||
- !githubUrl ||
- !githubUsername ||
- isSubmitting
- }
- >
- {isSubmitting ? "submitting..." : "submit for review"}
- </Button>
- </DialogFooter>
- </>
- )}
- </DialogContent>
- </Dialog>
- </>
- );
-};
diff --git a/apps/screenpipe-app-tauri/lib/api/index.ts b/apps/screenpipe-app-tauri/lib/api/index.ts
deleted file mode 100644
index 04b6d6270..000000000
--- a/apps/screenpipe-app-tauri/lib/api/index.ts
+++ /dev/null
@@ -1,111 +0,0 @@
-interface PipeCron {
- path: string;
- schedule: string;
-}
-
-interface PipeConfig {
- crons: PipeCron[];
- is_nextjs: boolean;
- source: string;
-}
-
-interface Pipe {
- config: PipeConfig;
- enabled: boolean;
- id: string;
- port: number | null;
- source: string;
-}
-
-interface PipeListResponse {
- data: Pipe[];
- success: boolean;
-}
-
-interface PipeShortcut {
- pipeId: string;
- shortcut: string;
-}
-
-export class PipeApi {
- private baseUrl: string;
-
- constructor(baseUrl: string = "http://localhost:3030") {
- this.baseUrl = baseUrl;
- }
-
- async listPipes(): Promise<Pipe[]> {
- try {
- const response = await fetch(`${this.baseUrl}/pipes/list`);
- if (!response.ok) {
- throw new Error(`failed to fetch pipes: ${response.statusText}`);
- }
- const data: PipeListResponse = await response.json();
- if (!data.success) {
- throw new Error("failed to list pipes: api returned success: false");
- }
- return data.data;
- } catch (error) {
- console.error("error listing pipes:", error);
- throw error;
- }
- }
-
- async startAudio(deviceName: string): Promise<void> {
- try {
- const type = deviceName.includes("(input)") ? "Input" : "Output";
- const name = deviceName.replaceAll("(input)", "").replaceAll("(output)", "").trim();
- const response = await fetch(`${this.baseUrl}/audio/start`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- device_name: name,
- device_type: type,
- }),
- });
-
- if (!response.ok) {
- throw new Error(`failed to start audio: ${response.statusText}`);
- }
-
- const data = await response.json();
- if (!data.success) {
- throw new Error(`failed to start audio: ${data.message}`);
- }
- } catch (error) {
- console.error("error starting audio:", error);
- throw error;
- }
- }
-
- async stopAudio(deviceName: string): Promise<void> {
- try {
- const type = deviceName.includes("(input)") ? "Input" : "Output";
- const name = deviceName.replaceAll("(input)", "").replaceAll("(output)", "").trim();
- const response = await fetch(`${this.baseUrl}/audio/stop`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- device_name: name,
- device_type: type,
- }),
- });
-
- if (!response.ok) {
- throw new Error(`failed to stop audio: ${response.statusText}`);
- }
-
- const data = await response.json();
- if (!data.success) {
- throw new Error(`failed to stop audio: ${data.message}`);
- }
- } catch (error) {
- console.error("error stopping audio:", error);
- throw error;
- }
- }
-}
diff --git a/apps/screenpipe-app-tauri/lib/api/store/index.ts b/apps/screenpipe-app-tauri/lib/api/store/index.ts
deleted file mode 100644
index 57f4d4756..000000000
--- a/apps/screenpipe-app-tauri/lib/api/store/index.ts
+++ /dev/null
@@ -1,361 +0,0 @@
-import { commands } from "../../utils/tauri";
-import localforage from "localforage";
-
-export interface PipeStorePlugin {
- id: string;
- name: string;
- description: string | null;
- is_paid: boolean | null;
- price: number | null;
- status: string | null;
- created_at: string | null;
- source_code: string | null;
- developer_accounts: {
- developer_name: string;
- };
- plugin_analytics: {
- downloads_count: number | null;
- };
-}
-
-export interface PipeDownloadResponse {
- download_url: string;
- file_hash: string;
- file_size: number;
-}
-
-export enum PipeDownloadError {
- PURCHASE_REQUIRED = "purchase required",
- DOWNLOAD_FAILED = "failed to download pipe",
-}
-
-type PurchaseHistoryResponse = PurchaseHistoryItem[];
-
-export interface PurchaseHistoryItem {
- id: string;
- amount_paid: number;
- currency: string;
- stripe_payment_status: string;
- created_at: string;
- refunded_at: string | null;
- plugin_id: string;
- plugin_name: string;
- plugin_description: string;
- developer_name: string;
-}
-
-interface PurchaseUrlResponse {
- data: {
- checkout_url?: string;
- used_credits?: boolean;
- payment_successful?: boolean;
- already_purchased?: boolean;
- };
-}
-
-export interface CheckUpdateResponse {
- has_update: boolean;
- current_version: string;
- latest_version: string;
- latest_file_hash: string;
- latest_file_size: number;
-}
-
-export interface CheckUpdatesRequest {
- plugins: Array<{
- pipe_id: string;
- version: string;
- }>;
-}
-
-export interface CheckUpdatesResponse {
- results: Array<
- | {
- pipe_id: string;
- has_update: boolean;
- current_version: string;
- latest_version: string;
- latest_file_hash: string;
- latest_file_size: number;
- }
- | {
- pipe_id: string;
- error: string;
- status: number;
- }
- >;
-}
-
-interface CacheEntry<T> {
- data: T;
- timestamp: number;
-}
-
-export class PipeApi {
- private baseUrl: string;
- private authToken: string;
- private cacheTTL = 60000; // 60 seconds cache
-
- private constructor(authToken: string) {
- this.baseUrl = "https://screenpi.pe";
- this.authToken = authToken;
- }
-
- static async create(authToken: string): Promise<PipeApi> {
- const api = new PipeApi(authToken);
- await api.init(authToken);
- return api;
- }
-
- private async init(authToken: string) {
- try {
- const BASE_URL = await commands.getEnv("BASE_URL_PRIVATE");
- if (BASE_URL) {
- this.baseUrl = BASE_URL as string;
- }
- this.authToken = authToken;
- } catch (error) {
- console.error("error initializing base url:", error);
- }
- }
-
- private async getCached<T>(key: string): Promise<T | null> {
- try {
- const entry = await localforage.getItem<CacheEntry<T>>(`pipe_api_${key}`);
- if (!entry) return null;
-
- if (Date.now() - entry.timestamp > this.cacheTTL) {
- await localforage.removeItem(`pipe_api_${key}`);
- return null;
- }
-
- return entry.data;
- } catch (error) {
- console.warn("cache read error:", error);
- return null;
- }
- }
-
- private async setCache<T>(key: string, data: T) {
- try {
- await localforage.setItem(`pipe_api_${key}`, {
- data,
- timestamp: Date.now(),
- });
- } catch (error) {
- console.warn("cache write error:", error);
- }
- }
-
- async getUserPurchaseHistory(): Promise<PurchaseHistoryResponse> {
- try {
- const response = await fetch(
- `${this.baseUrl}/api/plugins/user-purchase-history`,
- {
- headers: {
- Authorization: `Bearer ${this.authToken}`,
- },
- }
- );
- if (!response.ok) {
- const { error } = (await response.json()) as { error: string };
- throw new Error(`failed to fetch purchase history: ${error}`);
- }
-
- return (await response.json()) as PurchaseHistoryResponse;
- } catch (error) {
- console.error("error getting purchase history:", error);
- throw error;
- }
- }
-
- async listStorePlugins(): Promise<PipeStorePlugin[]> {
- const cacheKey = "store-plugins";
- const cached = await this.getCached<PipeStorePlugin[]>(cacheKey);
- if (cached) return cached;
-
- try {
- const response = await fetch(`${this.baseUrl}/api/plugins/registry`, {
- headers: {
- Authorization: `Bearer ${this.authToken}`,
- },
- });
- if (!response.ok) {
- const { error } = await response.json();
- throw new Error(`failed to fetch plugins: ${error}`);
- }
- const data: PipeStorePlugin[] = await response.json();
- await this.setCache(cacheKey, data);
- return data;
- } catch (error) {
- console.error("error listing pipes:", error);
- throw error;
- }
- }
-
- async purchasePipe(pipeId: string): Promise<PurchaseUrlResponse> {
- try {
- const response = await fetch(`${this.baseUrl}/api/plugins/purchase`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${this.authToken}`,
- },
- body: JSON.stringify({ pipe_id: pipeId }),
- });
- if (!response.ok) {
- const { error } = await response.json();
- throw new Error(`failed to purchase pipe: ${error}`);
- }
- const data = (await response.json()) as PurchaseUrlResponse;
- console.log("purchase data", data);
- return data;
- } catch (error) {
- console.error("error purchasing pipe:", error);
- throw error;
- }
- }
-
- async downloadPipe(pipeId: string): Promise<PipeDownloadResponse> {
- try {
- const response = await fetch(`${this.baseUrl}/api/plugins/download`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${this.authToken}`,
- },
- body: JSON.stringify({ pipe_id: pipeId }),
- });
-
- if (!response.ok) {
- const { error } = (await response.json()) as { error: string };
- throw new Error(error!, {
- cause:
- response.status === 403
- ? PipeDownloadError.PURCHASE_REQUIRED
- : PipeDownloadError.DOWNLOAD_FAILED,
- });
- }
- const data = (await response.json()) as PipeDownloadResponse;
- return data;
- } catch (error) {
- console.warn("error downloading pipe:", error);
- throw error;
- }
- }
-
- async checkUpdate(
- pipeId: string,
- version: string
- ): Promise<CheckUpdateResponse> {
- const cacheKey = `update_${pipeId}_${version}`;
- const cached = await this.getCached<CheckUpdateResponse>(cacheKey);
- if (cached) return cached;
-
- try {
- const response = await fetch(`${this.baseUrl}/api/plugins/check-update`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${this.authToken}`,
- },
- body: JSON.stringify({ pipe_id: pipeId, version }),
- });
-
- if (!response.ok) {
- const { error } = await response.json();
- throw new Error(`failed to check for updates: ${error}`);
- }
-
- const data = await response.json();
- await this.setCache(cacheKey, data);
- return data;
- } catch (error) {
- console.error("error checking for updates:", error);
- throw error;
- }
- }
-
- async checkUpdates(
- plugins: Array<{ pipe_id: string; version: string }>
- ): Promise<CheckUpdatesResponse> {
- // Filter out local plugins
- const localPlugins = plugins.filter(p => p.pipe_id.includes('_local'));
- const remotePlugins = plugins.filter(p => !p.pipe_id.includes('_local'));
-
- if (localPlugins.length > 0) {
- console.log(`[pipe-update] filtered out ${localPlugins.length} local plugins:`, localPlugins);
- }
-
-
- // If no remote plugins, return empty result
- if (remotePlugins.length === 0) {
- console.log("[pipe-update] no remote plugins to check for updates");
- return {
- results: []
- };
- }
-
- // Create a cache key based on remote plugin IDs and versions
- const cacheKey = `updates_${remotePlugins
- .map((p) => `${p.pipe_id}_${p.version}`)
- .join("_")}`;
- const cached = await this.getCached<CheckUpdatesResponse>(cacheKey);
- if (cached) {
- console.log("[pipe-update] returning cached update results");
- return cached;
- }
-
- try {
- console.log(`[pipe-update] sending update check request to server for ${remotePlugins.length} plugins`);
- const response = await fetch(`${this.baseUrl}/api/plugins/check-updates`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${this.authToken}`,
- },
- body: JSON.stringify({ plugins: remotePlugins }),
- });
-
- if (!response.ok) {
- const errorData = await response.json();
- console.error(`[pipe-update] server returned ${response.status}: ${JSON.stringify(errorData)}`);
- throw new Error(`failed to check for updates: ${errorData.error}`);
- }
-
- const data = await response.json();
- console.log("[pipe-update] received update check response:", data);
-
- // Add back information about local plugins
- if (localPlugins.length > 0) {
- console.log("[pipe-update] adding local plugin info to response");
- const localResults = localPlugins.map(p => ({
- pipe_id: p.pipe_id,
- error: "Local plugin cannot be checked for updates",
- status: 404
- }));
-
- // If data.results exists, add local results to it
- if (data.results) {
- data.results = [...data.results, ...localResults];
- }
- }
-
- await this.setCache(cacheKey, data);
- return data;
- } catch (error) {
- console.error("error checking for updates:", error);
- throw error;
- }
- }
-
- // method to force refresh cache if needed
- async clearCache() {
- const keys = await localforage.keys();
- await Promise.all(
- keys
- .filter((key) => key.startsWith("pipe_api_"))
- .map((key) => localforage.removeItem(key))
- );
- }
-}
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-pipes.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-pipes.tsx
deleted file mode 100644
index a6ab43c62..000000000
--- a/apps/screenpipe-app-tauri/lib/hooks/use-pipes.tsx
+++ /dev/null
@@ -1,343 +0,0 @@
-import { useState, useEffect } from "react";
-
-export type Pipe = {
- enabled: boolean;
- name: string;
- downloads: number;
- version: string;
- author: string;
- authorLink: string;
- repository: string;
- lastUpdate: string;
- description: string;
- fullDescription: string;
- mainFile?: string;
- config?: Record<string, any>;
-};
-
-const CACHE_DURATION = 60 * 60 * 1000; // 1 hour in milliseconds
-
-const fetchWithCache = async (url: string) => {
- const cacheKey = `cache_${url}`;
- const cachedData = localStorage.getItem(cacheKey);
-
- if (cachedData) {
- const { data, timestamp } = JSON.parse(cachedData);
- if (Date.now() - timestamp < CACHE_DURATION) {
- return data;
- }
- }
-
- try {
- const response = await fetch(url);
- if (response.status === 403) {
- throw new Error("Rate limit exceeded");
- }
- if (!response.ok) {
- throw new Error(`HTTP error! status: ${response.status}`);
- }
- const data = await response.json();
- localStorage.setItem(
- cacheKey,
- JSON.stringify({ data, timestamp: Date.now() })
- );
- return data;
- } catch (error) {
- console.error(`Error fetching ${url}:`, error);
- if (cachedData) {
- console.log("Returning stale cached data");
- return JSON.parse(cachedData).data;
- }
- throw error;
- }
-};
-
-const convertHtmlToMarkdown = (html: string) => {
- const convertedHtml = html.replace(
- /<img\s+(?:[^>]*?\s+)?src="([^"]*)"(?:\s+(?:[^>]*?\s+)?alt="([^"]*)")?\s*\/?>/g,
- (match, src, alt) => {
- return `![${alt || ""}](${src})`;
- }
- );
- return convertedHtml.replace(/<[^>]*>/g, "");
-};
-
-const fetchReadme = async (fullName: string) => {
- try {
- const data = await fetchWithCache(
- `https://api.github.com/repos/${fullName}/readme`
- );
- const decodedContent = atob(data.content);
- return convertHtmlToMarkdown(decodedContent);
- } catch (error) {
- console.error("error fetching readme:", error);
- return "";
- }
-};
-
-const fetchLatestRelease = async (fullName: string) => {
- try {
- const data = await fetchWithCache(
- `https://api.github.com/repos/${fullName}/releases/latest`
- );
- return data.tag_name;
- } catch (error) {
- console.error("error fetching latest release:", error);
- return "";
- }
-};
-
-const fetchSubdirContents = async (
- repoName: string,
- branch: string,
- path: string
-) => {
- try {
- return await fetchWithCache(
- `https://api.github.com/repos/${repoName}/contents/${path}?ref=${branch}`
- );
- } catch (error) {
- console.error(`Error fetching subdirectory contents: ${error}`);
- throw error;
- }
-};
-
-const fetchFileContent = async (
- repoName: string,
- branch: string,
- path: string
-) => {
- try {
- const data = await fetchWithCache(
- `https://api.github.com/repos/${repoName}/contents/${path}?ref=${branch}`
- );
- return atob(data.content);
- } catch (error) {
- console.error(`Error fetching file content: ${error}`);
- throw error;
- }
-};
-
-const fetchPipeConfig = async (
- repoFullName: string,
- branch: string,
- subDir: string
-): Promise<Record<string, any> | undefined> => {
- try {
- const configPath = subDir ? `${subDir}/pipe.json` : "pipe.json";
- const configContent = await fetchFileContent(
- repoFullName,
- branch,
- configPath
- );
- return JSON.parse(configContent);
- } catch (error) {
- console.error("Error fetching pipe config:", error);
- return undefined;
- }
-};
-
-export const usePipes = (initialRepoUrls: string[]) => {
- const [pipes, setPipes] = useState<Pipe[]>([]);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState<string | null>(null);
- const [repoUrls, setRepoUrls] = useState<string[]>(initialRepoUrls);
-
- const fetchPipeData = async (repoUrl: string): Promise<Pipe | null> => {
- console.log("fetchPipeData", repoUrl);
- try {
- const urlParts = repoUrl.split("/");
- const isSubdir = urlParts.length > 5;
- const repoOwner = urlParts[3];
- const repoName = urlParts[4];
- const repoFullName = `${repoOwner}/${repoName}`;
- const branch = isSubdir ? urlParts[6] : "main";
- const subDir = isSubdir ? urlParts.slice(7).join("/") : "";
- console.log("urlParts", urlParts);
- console.log("isSubdir", isSubdir);
- console.log("repoFullName", repoFullName);
- console.log("branch", branch);
- console.log("subDir", subDir);
- console.log("repoOwner", repoOwner);
- console.log("repoName", repoName);
- console.log(`Fetching repo data for ${repoFullName}`);
- const repoData = await fetchWithCache(
- `https://api.github.com/repos/${repoFullName}`
- );
-
- let pipeConfig: Record<string, any> | undefined;
-
- if (isSubdir) {
- console.log(
- `Fetching subdirectory contents for ${repoFullName}/${subDir}`
- );
- const contents = await fetchSubdirContents(
- repoFullName,
- branch,
- subDir
- );
- console.log("contents", contents);
- if (!contents || !Array.isArray(contents)) return null;
-
- const jsFiles = contents.filter(
- (file: any) => file.name.endsWith(".js") || file.name.endsWith(".ts")
- );
- const hasJsFile = jsFiles.length > 0;
- const readmeFile = contents.find(
- (file: any) => file.name.toLowerCase() === "readme.md"
- );
-
- if (!hasJsFile || !readmeFile) return null;
- console.log(`Fetching README content for ${repoFullName}/${subDir}`);
- const readmeContent = await fetchFileContent(
- repoFullName,
- branch,
- `${subDir}/${readmeFile.name}`
- );
-
- const mainFile =
- jsFiles.find((file: any) => file.name === "pipe.ts") || jsFiles[0];
- const mainFileUrl = mainFile
- ? `https://raw.githubusercontent.com/${repoFullName}/${branch}/${subDir}/${mainFile.name}`
- : undefined;
-
- console.log(`Fetching latest release for ${repoFullName}`);
-
- console.log(`Fetching pipe config for ${repoFullName}/${subDir}`);
- pipeConfig = await fetchPipeConfig(repoFullName, branch, subDir).catch(
- (error) => {
- console.warn("Error fetching pipe config:", error);
- return undefined;
- }
- );
-
- return {
- enabled: false,
- name: subDir.split("/").pop() || repoData.name,
- downloads: repoData.stargazers_count,
- version: await fetchLatestRelease(repoFullName),
- author: repoData.owner.login,
- authorLink: repoData.owner.html_url,
- repository: `${repoData.html_url}/tree/${branch}/${subDir}`,
- lastUpdate: repoData.updated_at,
- description: repoData.description,
- fullDescription: readmeContent
- ? convertHtmlToMarkdown(readmeContent)
- : "",
- mainFile: mainFileUrl,
- config: pipeConfig,
- };
- } else {
- console.log(`Fetching README for ${repoFullName}`);
- const fullDescription = await fetchReadme(repoFullName);
-
- console.log(`Fetching latest release for ${repoFullName}`);
- const version = await fetchLatestRelease(repoFullName);
-
- console.log(`Fetching pipe config for ${repoFullName}`);
- pipeConfig = await fetchPipeConfig(repoFullName, branch, "");
-
- return {
- enabled: false,
- name: repoData.name,
- downloads: repoData.stargazers_count,
- version,
- author: repoData.owner.login,
- authorLink: repoData.owner.html_url,
- repository: repoData.html_url,
- lastUpdate: repoData.updated_at,
- description: repoData.description,
- fullDescription,
- config: pipeConfig,
- };
- }
- } catch (error) {
- console.error(`Error processing ${repoUrl}:`, error);
- return null;
- }
- };
-
- useEffect(() => {
- let isMounted = true;
-
- const fetchPipes = async () => {
- if (!isMounted) return;
-
- setLoading(true);
- setError(null);
-
- try {
- const pipePromises = repoUrls.map(fetchPipeData);
- const fetchedPipes = (await Promise.all(pipePromises)).filter(
- Boolean
- ) as Pipe[];
-
- if (isMounted) {
- setPipes(fetchedPipes);
- }
- } catch (error) {
- console.error("Error in fetchPipes:", error);
- if (isMounted && !error) {
- setError("Failed to fetch pipes");
- }
- } finally {
- if (isMounted && loading) {
- setLoading(false);
- }
- }
-
- // get pipes from local api /pipes/list and add them to the list
- const localPipes = await fetch(`http://localhost:3030/pipes/list`).then(
- (res) => res.json()
- );
- // console.log("localPipes", localPipes);
- setPipes([
- ...pipes,
- ...localPipes.map((pipe: any) => ({
- ...pipe,
- name: pipe.id,
- })),
- ]);
- };
-
- fetchPipes();
-
- return () => {
- isMounted = false;
- };
- }, [repoUrls]);
-
- const addCustomPipe = async (newRepoUrl: string) => {
- setError(null);
-
- // Check if the URL already exists
- if (repoUrls.includes(newRepoUrl)) {
- setError("This pipe is already in the list.");
- return;
- }
-
- try {
- const newPipe = await fetchPipeData(newRepoUrl);
- console.log("newPipe", newPipe);
- if (newPipe) {
- // Check if a pipe with the same name already exists
- if (pipes.some((pipe) => pipe.name === newPipe.name)) {
- setError("A pipe with this name already exists.");
- return;
- }
-
- setRepoUrls((prevUrls) => [...prevUrls, newRepoUrl]);
- setPipes((prevPipes) => [...prevPipes, newPipe]);
- } else {
- throw new Error("Failed to fetch pipe data");
- }
- } catch (error) {
- console.error("Error adding custom pipe:", error);
- setError(
- error instanceof Error ? error.message : "Failed to add custom pipe"
- );
- }
- };
-
- return { pipes, loading, error, addCustomPipe };
-};