opencode-island 0.0.0-stage → 0.2.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.
@@ -0,0 +1,63 @@
1
+ import * as React from "react"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+ import { cn } from "@/lib/utils"
4
+ import { Slot } from "radix-ui"
5
+
6
+ const buttonVariants = cva(
7
+ "inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
12
+ destructive:
13
+ "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
14
+ outline:
15
+ "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
16
+ secondary:
17
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80",
18
+ ghost:
19
+ "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
20
+ link: "text-primary underline-offset-4 hover:underline",
21
+ },
22
+ size: {
23
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
24
+ xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
25
+ sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
26
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
27
+ icon: "size-9",
28
+ "icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
29
+ "icon-sm": "size-8",
30
+ "icon-lg": "size-10",
31
+ },
32
+ },
33
+ defaultVariants: {
34
+ variant: "default",
35
+ size: "default",
36
+ },
37
+ }
38
+ )
39
+
40
+ function Button({
41
+ className,
42
+ variant = "default",
43
+ size = "default",
44
+ asChild = false,
45
+ ...props
46
+ }: React.ComponentProps<"button"> &
47
+ VariantProps<typeof buttonVariants> & {
48
+ asChild?: boolean
49
+ }) {
50
+ const Comp = asChild ? Slot.Root : "button"
51
+
52
+ return (
53
+ <Comp
54
+ data-slot="button"
55
+ data-variant={variant}
56
+ data-size={size}
57
+ className={cn(buttonVariants({ variant, size, className }))}
58
+ {...props}
59
+ />
60
+ )
61
+ }
62
+
63
+ export { Button, buttonVariants }
@@ -0,0 +1,44 @@
1
+ import * as React from "react"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+ import { cn } from "@/lib/utils"
4
+ import { Toggle as TogglePrimitive } from "radix-ui"
5
+
6
+ const toggleVariants = cva(
7
+ "inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none hover:bg-muted hover:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-transparent",
12
+ outline:
13
+ "border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground",
14
+ },
15
+ size: {
16
+ default: "h-9 min-w-9 px-2",
17
+ sm: "h-8 min-w-8 px-1.5",
18
+ lg: "h-10 min-w-10 px-2.5",
19
+ },
20
+ },
21
+ defaultVariants: {
22
+ variant: "default",
23
+ size: "default",
24
+ },
25
+ }
26
+ )
27
+
28
+ function Toggle({
29
+ className,
30
+ variant,
31
+ size,
32
+ ...props
33
+ }: React.ComponentProps<typeof TogglePrimitive.Root> &
34
+ VariantProps<typeof toggleVariants>) {
35
+ return (
36
+ <TogglePrimitive.Root
37
+ data-slot="toggle"
38
+ className={cn(toggleVariants({ variant, size, className }))}
39
+ {...props}
40
+ />
41
+ )
42
+ }
43
+
44
+ export { Toggle, toggleVariants }
@@ -0,0 +1,22 @@
1
+ import type { IslandMessage, PermissionDecision } from "../../state"
2
+
3
+ declare global {
4
+ interface Window {
5
+ island: {
6
+ ready: () => void
7
+ size: (width: number, height: number) => void
8
+ toggle: () => void
9
+ reply: (reply: { sessionID: string; requestID: string; decision: PermissionDecision }) => void
10
+ dragStart: () => void
11
+ dragEnd: () => void
12
+ ignore: (ignore: boolean) => void
13
+ resizeStart: () => void
14
+ resize: (screenY: number) => void
15
+ resizeEnd: () => void
16
+ screen: () => Promise<{ width: number; height: number }>
17
+ onState: (handler: (state: IslandMessage) => void) => void
18
+ }
19
+ }
20
+ }
21
+
22
+ export {}
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta
6
+ http-equiv="Content-Security-Policy"
7
+ content="default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; img-src data:"
8
+ />
9
+ <title>OpenCode Island</title>
10
+ </head>
11
+ <body>
12
+ <div id="root"></div>
13
+ <script type="module" src="/main.tsx"></script>
14
+ </body>
15
+ </html>
@@ -0,0 +1,101 @@
1
+ @import "tailwindcss";
2
+
3
+ @theme inline {
4
+ --color-background: var(--background);
5
+ --color-foreground: var(--foreground);
6
+ --color-card: var(--card);
7
+ --color-card-foreground: var(--card-foreground);
8
+ --color-primary: var(--primary);
9
+ --color-primary-foreground: var(--primary-foreground);
10
+ --color-secondary: var(--secondary);
11
+ --color-secondary-foreground: var(--secondary-foreground);
12
+ --color-muted: var(--muted);
13
+ --color-muted-foreground: var(--muted-foreground);
14
+ --color-accent: var(--accent);
15
+ --color-accent-foreground: var(--accent-foreground);
16
+ --color-destructive: var(--destructive);
17
+ --color-border: var(--border);
18
+ --color-input: var(--input);
19
+ --color-ring: var(--ring);
20
+ --color-success: var(--success);
21
+ --color-warning: var(--warning);
22
+ --color-warning-foreground: var(--warning-foreground);
23
+ --radius-sm: calc(var(--radius) - 4px);
24
+ --radius-md: calc(var(--radius) - 2px);
25
+ --radius-lg: var(--radius);
26
+ --radius-xl: calc(var(--radius) + 4px);
27
+ }
28
+
29
+ /* Dark is the island's own look; light is one switch away. */
30
+ :root {
31
+ --radius: 0.5rem;
32
+ --background: #000000;
33
+ --foreground: #f5f5f7;
34
+ --card: #000000;
35
+ --card-foreground: #f5f5f7;
36
+ --primary: #f5f5f7;
37
+ --primary-foreground: #0a0a0a;
38
+ --secondary: #2c2c2e;
39
+ --secondary-foreground: #f5f5f7;
40
+ --muted: #2c2c2e;
41
+ --muted-foreground: #8e8e93;
42
+ --accent: #2c2c2e;
43
+ --accent-foreground: #f5f5f7;
44
+ --destructive: #ff453a;
45
+ --border: rgba(255, 255, 255, 0.12);
46
+ --input: rgba(255, 255, 255, 0.18);
47
+ --ring: rgba(255, 255, 255, 0.5);
48
+ --success: #30d158;
49
+ --warning: #ff9f0a;
50
+ --warning-foreground: #1c1200;
51
+ }
52
+
53
+ [data-theme="light"] {
54
+ --background: #ffffff;
55
+ --foreground: #1d1d1f;
56
+ --card: #ffffff;
57
+ --card-foreground: #1d1d1f;
58
+ --primary: #1d1d1f;
59
+ --primary-foreground: #ffffff;
60
+ --secondary: #e8e8ed;
61
+ --secondary-foreground: #1d1d1f;
62
+ --muted: #e8e8ed;
63
+ --muted-foreground: #6e6e73;
64
+ --accent: #e8e8ed;
65
+ --accent-foreground: #1d1d1f;
66
+ --destructive: #d70015;
67
+ --border: rgba(0, 0, 0, 0.12);
68
+ --input: rgba(0, 0, 0, 0.18);
69
+ --ring: rgba(0, 0, 0, 0.4);
70
+ --success: #248a3d;
71
+ }
72
+
73
+ @layer base {
74
+ * {
75
+ @apply border-border outline-ring/50;
76
+ }
77
+
78
+ html,
79
+ body,
80
+ #root {
81
+ height: 100%;
82
+ background: transparent;
83
+ }
84
+
85
+ /* The shell hugs the screen edge, so the window can grow and shrink around it. */
86
+ #root {
87
+ display: flex;
88
+ align-items: center;
89
+ justify-content: flex-end;
90
+ }
91
+
92
+ body {
93
+ margin: 0;
94
+ overflow: hidden;
95
+ font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
96
+ -webkit-font-smoothing: antialiased;
97
+ color: var(--foreground);
98
+ user-select: none;
99
+ cursor: default;
100
+ }
101
+ }
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
@@ -0,0 +1,10 @@
1
+ import { StrictMode } from "react"
2
+ import { createRoot } from "react-dom/client"
3
+ import { Island } from "@/components/island"
4
+ import "./island.css"
5
+
6
+ createRoot(document.getElementById("root")!).render(
7
+ <StrictMode>
8
+ <Island />
9
+ </StrictMode>,
10
+ )
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ES2023", "DOM", "DOM.Iterable"],
7
+ "jsx": "react-jsx",
8
+ "strict": true,
9
+ "noEmit": true,
10
+ "skipLibCheck": true,
11
+ "esModuleInterop": true,
12
+ "allowImportingTsExtensions": true,
13
+ "types": [],
14
+ "baseUrl": ".",
15
+ "paths": {
16
+ "@/*": ["./*"]
17
+ }
18
+ },
19
+ "include": ["./**/*.ts", "./**/*.tsx", "../../state.ts"]
20
+ }
@@ -0,0 +1,20 @@
1
+ const { contextBridge, ipcRenderer } = require("electron")
2
+
3
+ /**
4
+ * The island page's only way out. It can report its size, ask for a toggle and
5
+ * answer a permission; it cannot reach Node, the filesystem or the network.
6
+ */
7
+ contextBridge.exposeInMainWorld("island", {
8
+ ready: () => ipcRenderer.send("opencode-island:ready"),
9
+ size: (width, height) => ipcRenderer.send("opencode-island:size", { width, height }),
10
+ toggle: () => ipcRenderer.send("opencode-island:toggle"),
11
+ reply: (reply) => ipcRenderer.send("opencode-island:reply", reply),
12
+ dragStart: () => ipcRenderer.send("opencode-island:drag-start"),
13
+ dragEnd: () => ipcRenderer.send("opencode-island:drag-end"),
14
+ ignore: (ignore) => ipcRenderer.send("opencode-island:ignore", ignore),
15
+ resizeStart: () => ipcRenderer.send("opencode-island:resize-start"),
16
+ resize: (screenY) => ipcRenderer.send("opencode-island:resize", screenY),
17
+ resizeEnd: () => ipcRenderer.send("opencode-island:resize-end"),
18
+ screen: () => ipcRenderer.invoke("opencode-island:screen"),
19
+ onState: (handler) => ipcRenderer.on("opencode-island:state", (_event, state) => handler(state)),
20
+ })