ramonai-widget 0.1.8 → 0.1.10
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 +3 -60
- package/dist/ramonai-widget.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
```markdown
|
|
2
1
|
# RamonAI Widget
|
|
3
2
|
|
|
4
3
|
A responsive shopping assistant widget built with React and Vite. It renders a floating launcher and a chat panel that you can drop into any storefront.
|
|
5
4
|
|
|
6
|
-
## Local development
|
|
7
|
-
|
|
8
|
-
Install dependencies and run the demo page:
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
npm install
|
|
12
|
-
npm run dev
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Build (production)
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm run build
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
The build outputs a single browser-safe bundle at `dist/ramonai-widget.js` (IIFE, styles inlined). It does not require Node.js polyfills in the browser.
|
|
22
|
-
|
|
23
5
|
## Usage / embedding
|
|
24
6
|
|
|
25
|
-
###
|
|
7
|
+
### Single tag (CDN or self-hosted)
|
|
26
8
|
|
|
27
9
|
Add one script tag anywhere in your page. Works in all projects (vanilla HTML, React, Vue, Next.js, etc.). `type="module"` is fine, but not required.
|
|
28
10
|
|
|
@@ -32,7 +14,7 @@ Add one script tag anywhere in your page. Works in all projects (vanilla HTML, R
|
|
|
32
14
|
id="ramonai-widget"
|
|
33
15
|
src="https://cdn.jsdelivr.net/npm/ramonai-widget@latest/dist/ramonai-widget.js"
|
|
34
16
|
data-shop-name="Your Shop"
|
|
35
|
-
data-accent="#242424"
|
|
17
|
+
<!-- data-accent="#242424" -->
|
|
36
18
|
<!-- data-target="#ramonai-host" -->
|
|
37
19
|
></script>
|
|
38
20
|
```
|
|
@@ -45,26 +27,6 @@ Supported attributes map to the public API:
|
|
|
45
27
|
|
|
46
28
|
Note: `data-autoinit` is not required. The widget auto-initializes when it detects the `id="ramonai-widget"` script or any meaningful config attributes.
|
|
47
29
|
|
|
48
|
-
### 2) Programmatic init (optional)
|
|
49
|
-
|
|
50
|
-
Load the bundle and call the global API:
|
|
51
|
-
|
|
52
|
-
```html
|
|
53
|
-
<script src="/ramonai-widget.js"></script>
|
|
54
|
-
<script>
|
|
55
|
-
window.RamonAIWidget?.init({
|
|
56
|
-
shopName: "Example Shop",
|
|
57
|
-
accent: "#242424",
|
|
58
|
-
// target: document.querySelector('#ramonai-host'), // optional
|
|
59
|
-
});
|
|
60
|
-
// Later
|
|
61
|
-
// window.RamonAIWidget?.destroyAll();
|
|
62
|
-
// or keep the handle:
|
|
63
|
-
// const inst = window.RamonAIWidget?.init(...);
|
|
64
|
-
// inst?.destroy();
|
|
65
|
-
</script>
|
|
66
|
-
```
|
|
67
|
-
|
|
68
30
|
### Options
|
|
69
31
|
|
|
70
32
|
| name | type | default | description |
|
|
@@ -76,23 +38,4 @@ Load the bundle and call the global API:
|
|
|
76
38
|
Notes:
|
|
77
39
|
|
|
78
40
|
- The script auto-initializes from the tag and reads the attributes listed above. `data-accent-color` is accepted as an alias for `data-accent`.
|
|
79
|
-
- The library build inlines `process.env` at build time, so no client polyfills are necessary.
|
|
80
|
-
|
|
81
|
-
## Project structure
|
|
82
|
-
|
|
83
|
-
- `src/embed.tsx`: public embed API, auto-init, and mounting helpers.
|
|
84
|
-
- `src/widget/WidgetApp.tsx`: main widget UI and chat logic.
|
|
85
|
-
- `src/styles.css`: widget styles (inlined into the bundle).
|
|
86
|
-
- `src/main.tsx`: demo page used during local development.
|
|
87
|
-
|
|
88
|
-
## Backend configuration (.env)
|
|
89
|
-
|
|
90
|
-
The chat API base URL is configured at build time via Vite env:
|
|
91
|
-
|
|
92
|
-
```
|
|
93
|
-
VITE_API_BASE_URL=https://your-api.example.com/v1
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Create a `.env` (or `.env.production`) file with the variable above before running `npm run build`. The bundle will embed this value. At runtime, the widget cannot read server-side env; you must set it at build time.
|
|
97
|
-
|
|
98
|
-
`WidgetApp` posts messages to this `VITE_API_BASE_URL` and renders product suggestions from responses.
|
|
41
|
+
- The library build inlines `process.env` at build time, so no client polyfills are necessary.
|