@patchedcodes/hackathon-widget 0.1.0 → 0.1.2
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/README.md +91 -0
- package/dist/devloyed-widget.js +5945 -0
- package/dist/devloyed-widget.js.map +1 -0
- package/dist/index.d.ts +278 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @patchedcodes/hackathon-widget
|
|
2
|
+
|
|
3
|
+
AI-powered frontend editor widget — modify live web interfaces using natural language.
|
|
4
|
+
|
|
5
|
+
Renders a floating chat button on your page. Users type a natural-language command, the widget captures a screenshot, sends it to your backend, and applies the resulting changes.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @patchedcodes/hackathon-widget
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
or
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @patchedcodes/hackathon-widget
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { init } from "@patchedcodes/hackathon-widget";
|
|
23
|
+
|
|
24
|
+
init({
|
|
25
|
+
endpoint: "https://your-backend.com/api/command",
|
|
26
|
+
projectId: "my-project",
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
That's it. A floating button appears in the bottom-right corner of your page.
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
`init()` accepts a `WidgetConfig` object:
|
|
35
|
+
|
|
36
|
+
| Option | Type | Default | Description |
|
|
37
|
+
|---|---|---|---|
|
|
38
|
+
| `endpoint` | `string` | **(required)** | Backend URL that receives command POST requests. |
|
|
39
|
+
| `projectId` | `string` | **(required)** | Project identifier sent with each request so the backend knows which repo to modify. |
|
|
40
|
+
| `position` | `"bottom-right" \| "bottom-left" \| "top-right" \| "top-left"` | `"bottom-right"` | Position of the floating widget button. |
|
|
41
|
+
| `theme` | `"light" \| "dark"` | `"light"` | Widget color theme. |
|
|
42
|
+
| `headers` | `Record<string, string>` | `{}` | Custom headers sent with backend requests (e.g. auth tokens). |
|
|
43
|
+
| `onDeployReady` | `(branch: string, previewUrl: string) => void` | — | Called when a deployment is ready, before the user clicks "Apply". |
|
|
44
|
+
| `onError` | `(error: Error) => void` | — | Called when an error occurs. |
|
|
45
|
+
| `onOpen` | `() => void` | — | Called when the widget panel is opened. |
|
|
46
|
+
| `onClose` | `() => void` | — | Called when the widget panel is closed. |
|
|
47
|
+
|
|
48
|
+
## Callbacks
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
init({
|
|
52
|
+
endpoint: "https://your-backend.com/api/command",
|
|
53
|
+
projectId: "my-project",
|
|
54
|
+
onDeployReady: (branch, previewUrl) => {
|
|
55
|
+
console.log(`Deploy ready on branch ${branch}: ${previewUrl}`);
|
|
56
|
+
},
|
|
57
|
+
onError: (error) => {
|
|
58
|
+
console.error("Widget error:", error);
|
|
59
|
+
},
|
|
60
|
+
onOpen: () => console.log("Widget opened"),
|
|
61
|
+
onClose: () => console.log("Widget closed"),
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Programmatic Control
|
|
66
|
+
|
|
67
|
+
`init()` returns the underlying `DevloyedWidget` custom element, which exposes methods for programmatic control:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
const widget = init({
|
|
71
|
+
endpoint: "https://your-backend.com/api/command",
|
|
72
|
+
projectId: "my-project",
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Open, close, or toggle the chat panel
|
|
76
|
+
widget.open();
|
|
77
|
+
widget.close();
|
|
78
|
+
widget.toggle();
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## TypeScript
|
|
82
|
+
|
|
83
|
+
Types are shipped with the package — no separate `@types/` install needed. You can import them directly:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import type { WidgetConfig } from "@patchedcodes/hackathon-widget";
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
MIT
|