@orello/react 0.1.4 → 0.1.5
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/dist/index.cjs +1 -137
- package/dist/index.d.cts +12 -7
- package/dist/index.d.ts +12 -7
- package/dist/index.js +1 -110
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,137 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
OrelloWidget: () => OrelloWidget
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(index_exports);
|
|
26
|
-
|
|
27
|
-
// src/OrelloWidget.tsx
|
|
28
|
-
var import_react = require("react");
|
|
29
|
-
var DEFAULT_SCRIPT_SRC = "https://cdn.orello.ai/orello.js";
|
|
30
|
-
function setOptionalAttribute(el, name, value) {
|
|
31
|
-
if (!value) return;
|
|
32
|
-
el.setAttribute(name, value);
|
|
33
|
-
}
|
|
34
|
-
function getExistingScript(scriptSrc) {
|
|
35
|
-
var _a;
|
|
36
|
-
const scripts = Array.from(document.querySelectorAll("script[src]"));
|
|
37
|
-
return (_a = scripts.find(
|
|
38
|
-
(item) => item.getAttribute("data-orello-react") === "true" && item.getAttribute("src") === scriptSrc
|
|
39
|
-
)) != null ? _a : null;
|
|
40
|
-
}
|
|
41
|
-
function OrelloWidget({
|
|
42
|
-
widgetKey,
|
|
43
|
-
assistantId,
|
|
44
|
-
scriptSrc = DEFAULT_SCRIPT_SRC,
|
|
45
|
-
apiBase,
|
|
46
|
-
agentEndpoint,
|
|
47
|
-
widgetUrl,
|
|
48
|
-
wakeWord = true,
|
|
49
|
-
onReady,
|
|
50
|
-
onError,
|
|
51
|
-
cleanupOnUnmount = false
|
|
52
|
-
}) {
|
|
53
|
-
(0, import_react.useEffect)(() => {
|
|
54
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (!widgetKey || !widgetKey.trim()) {
|
|
58
|
-
console.error("[Orello React] Missing required prop: widgetKey");
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const handleReady = (event) => {
|
|
62
|
-
onReady == null ? void 0 : onReady(event);
|
|
63
|
-
};
|
|
64
|
-
const handleError = (event) => {
|
|
65
|
-
onError == null ? void 0 : onError(event);
|
|
66
|
-
};
|
|
67
|
-
window.addEventListener("orello:ready", handleReady);
|
|
68
|
-
window.addEventListener("orello:error", handleError);
|
|
69
|
-
const resolvedScriptSrc = scriptSrc.trim() || DEFAULT_SCRIPT_SRC;
|
|
70
|
-
const existingScript = getExistingScript(resolvedScriptSrc);
|
|
71
|
-
if (!existingScript) {
|
|
72
|
-
const script = document.createElement("script");
|
|
73
|
-
script.src = resolvedScriptSrc;
|
|
74
|
-
script.async = true;
|
|
75
|
-
script.setAttribute("data-orello-react", "true");
|
|
76
|
-
script.setAttribute("data-api-key", widgetKey);
|
|
77
|
-
script.setAttribute("data-key", widgetKey);
|
|
78
|
-
script.setAttribute("data-wake-word", wakeWord ? "true" : "false");
|
|
79
|
-
setOptionalAttribute(script, "data-agent-id", assistantId);
|
|
80
|
-
setOptionalAttribute(script, "data-api-base", apiBase);
|
|
81
|
-
setOptionalAttribute(script, "data-agent-endpoint", agentEndpoint);
|
|
82
|
-
setOptionalAttribute(script, "data-widget-url", widgetUrl);
|
|
83
|
-
document.head.appendChild(script);
|
|
84
|
-
return () => {
|
|
85
|
-
window.removeEventListener("orello:ready", handleReady);
|
|
86
|
-
window.removeEventListener("orello:error", handleError);
|
|
87
|
-
if (cleanupOnUnmount) {
|
|
88
|
-
const root = document.getElementById("orello-widget-root");
|
|
89
|
-
if (root) root.remove();
|
|
90
|
-
script.remove();
|
|
91
|
-
delete window.OrelloWidget;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
existingScript.setAttribute("data-api-key", widgetKey);
|
|
96
|
-
existingScript.setAttribute("data-key", widgetKey);
|
|
97
|
-
existingScript.setAttribute("data-wake-word", wakeWord ? "true" : "false");
|
|
98
|
-
if (assistantId) {
|
|
99
|
-
existingScript.setAttribute("data-agent-id", assistantId);
|
|
100
|
-
}
|
|
101
|
-
if (apiBase) {
|
|
102
|
-
existingScript.setAttribute("data-api-base", apiBase);
|
|
103
|
-
}
|
|
104
|
-
if (agentEndpoint) {
|
|
105
|
-
existingScript.setAttribute("data-agent-endpoint", agentEndpoint);
|
|
106
|
-
}
|
|
107
|
-
if (widgetUrl) {
|
|
108
|
-
existingScript.setAttribute("data-widget-url", widgetUrl);
|
|
109
|
-
}
|
|
110
|
-
return () => {
|
|
111
|
-
window.removeEventListener("orello:ready", handleReady);
|
|
112
|
-
window.removeEventListener("orello:error", handleError);
|
|
113
|
-
if (cleanupOnUnmount) {
|
|
114
|
-
const root = document.getElementById("orello-widget-root");
|
|
115
|
-
if (root) root.remove();
|
|
116
|
-
existingScript.remove();
|
|
117
|
-
delete window.OrelloWidget;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
}, [
|
|
121
|
-
widgetKey,
|
|
122
|
-
assistantId,
|
|
123
|
-
scriptSrc,
|
|
124
|
-
apiBase,
|
|
125
|
-
agentEndpoint,
|
|
126
|
-
widgetUrl,
|
|
127
|
-
wakeWord,
|
|
128
|
-
onReady,
|
|
129
|
-
onError,
|
|
130
|
-
cleanupOnUnmount
|
|
131
|
-
]);
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
-
0 && (module.exports = {
|
|
136
|
-
OrelloWidget
|
|
137
|
-
});
|
|
1
|
+
"use strict";var b=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var K=(o,t)=>{for(var r in t)b(o,r,{get:t[r],enumerable:!0})},M=(o,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of P(t))!T.call(o,l)&&l!==r&&b(o,l,{get:()=>t[l],enumerable:!(i=R(t,l))||i.enumerable});return o};var W=o=>M(b({},"__esModule",{value:!0}),o);var D={};K(D,{OrelloAgent:()=>C});module.exports=W(D);var x=require("react"),k=require("react/jsx-runtime"),h="https://cdn.jsdelivr.net/npm/@orello/sdk@0.0.85/dist/orello.min.js";function a(o,t,r){r&&o.setAttribute(t,r)}function q(o){var r;return(r=Array.from(document.querySelectorAll("script[src]")).find(i=>i.getAttribute("data-orello-react")==="true"&&i.getAttribute("src")===o))!=null?r:null}function C({apiKey:o,widgetKey:t,assistantId:r,agent:i,scriptSrc:l=h,apiBase:u="https://api.ai.orello.space/api/v1",agentEndpoint:c="https://api.agent.orello.space",widgetUrl:g,wakeWord:f=!1,onReady:p,onError:v,onNavigate:m,cleanupOnUnmount:w=!1}){return(0,x.useEffect)(()=>{if(typeof window=="undefined"||typeof document=="undefined")return;let s=o||t;if(!s||!s.trim()){console.error("[Orello React] Missing required prop: apiKey or widgetKey");return}let A=e=>{p==null||p(e)},E=e=>{v==null||v(e)},y=e=>{var S;let d=e;(S=d.detail)!=null&&S.url&&(e.preventDefault(),m&&m(d.detail.url))};window.addEventListener("orello:ready",A),window.addEventListener("orello:error",E),window.addEventListener("orello:navigate",y);let L=l.trim()||h,n=q(L),O=typeof i=="string"?i:i?JSON.stringify(i):void 0;if(!n){let e=document.createElement("script");return e.src=L,e.async=!0,e.setAttribute("data-orello-react","true"),e.setAttribute("data-api-key",s),e.setAttribute("data-key",s),e.setAttribute("data-wake-word",f?"true":"false"),a(e,"data-agent-id",r),a(e,"data-api-base",u),a(e,"data-agent-service-url",c),a(e,"data-widget-url",g),a(e,"data-agent",O),document.head.appendChild(e),()=>{if(window.removeEventListener("orello:ready",A),window.removeEventListener("orello:error",E),window.removeEventListener("orello:navigate",y),w){let d=document.getElementById("orello-widget-root");d&&d.remove(),e.remove(),delete window.OrelloWidget}}}return n.setAttribute("data-api-key",s),n.setAttribute("data-key",s),n.setAttribute("data-wake-word",f?"true":"false"),r&&n.setAttribute("data-agent-id",r),u&&n.setAttribute("data-api-base",u),c&&n.setAttribute("data-agent-service-url",c),g&&n.setAttribute("data-widget-url",g),O&&n.setAttribute("data-agent",O),()=>{if(window.removeEventListener("orello:ready",A),window.removeEventListener("orello:error",E),window.removeEventListener("orello:navigate",y),w){let e=document.getElementById("orello-widget-root");e&&e.remove(),n.remove(),delete window.OrelloWidget}}},[o,t,r,i,l,u,c,g,f,p,v,m,w]),(0,k.jsx)("div",{id:"orello-widget-host",style:{position:"fixed",zIndex:2147483e3}})}0&&(module.exports={OrelloAgent});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type OrelloAgentConfig = {
|
|
2
4
|
uid?: string;
|
|
3
5
|
name?: string;
|
|
4
6
|
description?: string;
|
|
@@ -34,7 +36,7 @@ type OrelloWidgetActions = {
|
|
|
34
36
|
type OrelloRuntimeApi = {
|
|
35
37
|
version: string;
|
|
36
38
|
config: OrelloWidgetConfig;
|
|
37
|
-
agent?:
|
|
39
|
+
agent?: OrelloAgentConfig;
|
|
38
40
|
open: () => void;
|
|
39
41
|
close: () => void;
|
|
40
42
|
toggle: () => void;
|
|
@@ -42,7 +44,7 @@ type OrelloRuntimeApi = {
|
|
|
42
44
|
getDom: (path?: string) => unknown;
|
|
43
45
|
};
|
|
44
46
|
type OrelloReadyEvent = CustomEvent<{
|
|
45
|
-
agent?:
|
|
47
|
+
agent?: OrelloAgentConfig;
|
|
46
48
|
}>;
|
|
47
49
|
type OrelloErrorEvent = CustomEvent<{
|
|
48
50
|
message?: string;
|
|
@@ -53,9 +55,11 @@ declare global {
|
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
type
|
|
57
|
-
|
|
58
|
+
type OrelloAgentProps = {
|
|
59
|
+
apiKey?: string;
|
|
60
|
+
widgetKey?: string;
|
|
58
61
|
assistantId?: string;
|
|
62
|
+
agent?: OrelloAgentConfig | string;
|
|
59
63
|
scriptSrc?: string;
|
|
60
64
|
apiBase?: string;
|
|
61
65
|
agentEndpoint?: string;
|
|
@@ -63,8 +67,9 @@ type OrelloWidgetProps = {
|
|
|
63
67
|
wakeWord?: boolean;
|
|
64
68
|
onReady?: (event: OrelloReadyEvent) => void;
|
|
65
69
|
onError?: (event: OrelloErrorEvent) => void;
|
|
70
|
+
onNavigate?: (url: string) => void;
|
|
66
71
|
cleanupOnUnmount?: boolean;
|
|
67
72
|
};
|
|
68
|
-
declare function
|
|
73
|
+
declare function OrelloAgent({ apiKey, widgetKey, assistantId, agent, scriptSrc, apiBase, agentEndpoint, widgetUrl, wakeWord, onReady, onError, onNavigate, cleanupOnUnmount, }: OrelloAgentProps): react_jsx_runtime.JSX.Element;
|
|
69
74
|
|
|
70
|
-
export { type
|
|
75
|
+
export { OrelloAgent, type OrelloAgentConfig, type OrelloAgentProps, type OrelloErrorEvent, type OrelloReadyEvent, type OrelloRuntimeApi, type OrelloWidgetActions, type OrelloWidgetConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type OrelloAgentConfig = {
|
|
2
4
|
uid?: string;
|
|
3
5
|
name?: string;
|
|
4
6
|
description?: string;
|
|
@@ -34,7 +36,7 @@ type OrelloWidgetActions = {
|
|
|
34
36
|
type OrelloRuntimeApi = {
|
|
35
37
|
version: string;
|
|
36
38
|
config: OrelloWidgetConfig;
|
|
37
|
-
agent?:
|
|
39
|
+
agent?: OrelloAgentConfig;
|
|
38
40
|
open: () => void;
|
|
39
41
|
close: () => void;
|
|
40
42
|
toggle: () => void;
|
|
@@ -42,7 +44,7 @@ type OrelloRuntimeApi = {
|
|
|
42
44
|
getDom: (path?: string) => unknown;
|
|
43
45
|
};
|
|
44
46
|
type OrelloReadyEvent = CustomEvent<{
|
|
45
|
-
agent?:
|
|
47
|
+
agent?: OrelloAgentConfig;
|
|
46
48
|
}>;
|
|
47
49
|
type OrelloErrorEvent = CustomEvent<{
|
|
48
50
|
message?: string;
|
|
@@ -53,9 +55,11 @@ declare global {
|
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
type
|
|
57
|
-
|
|
58
|
+
type OrelloAgentProps = {
|
|
59
|
+
apiKey?: string;
|
|
60
|
+
widgetKey?: string;
|
|
58
61
|
assistantId?: string;
|
|
62
|
+
agent?: OrelloAgentConfig | string;
|
|
59
63
|
scriptSrc?: string;
|
|
60
64
|
apiBase?: string;
|
|
61
65
|
agentEndpoint?: string;
|
|
@@ -63,8 +67,9 @@ type OrelloWidgetProps = {
|
|
|
63
67
|
wakeWord?: boolean;
|
|
64
68
|
onReady?: (event: OrelloReadyEvent) => void;
|
|
65
69
|
onError?: (event: OrelloErrorEvent) => void;
|
|
70
|
+
onNavigate?: (url: string) => void;
|
|
66
71
|
cleanupOnUnmount?: boolean;
|
|
67
72
|
};
|
|
68
|
-
declare function
|
|
73
|
+
declare function OrelloAgent({ apiKey, widgetKey, assistantId, agent, scriptSrc, apiBase, agentEndpoint, widgetUrl, wakeWord, onReady, onError, onNavigate, cleanupOnUnmount, }: OrelloAgentProps): react_jsx_runtime.JSX.Element;
|
|
69
74
|
|
|
70
|
-
export { type
|
|
75
|
+
export { OrelloAgent, type OrelloAgentConfig, type OrelloAgentProps, type OrelloErrorEvent, type OrelloReadyEvent, type OrelloRuntimeApi, type OrelloWidgetActions, type OrelloWidgetConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,110 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
var DEFAULT_SCRIPT_SRC = "https://cdn.orello.ai/orello.js";
|
|
4
|
-
function setOptionalAttribute(el, name, value) {
|
|
5
|
-
if (!value) return;
|
|
6
|
-
el.setAttribute(name, value);
|
|
7
|
-
}
|
|
8
|
-
function getExistingScript(scriptSrc) {
|
|
9
|
-
var _a;
|
|
10
|
-
const scripts = Array.from(document.querySelectorAll("script[src]"));
|
|
11
|
-
return (_a = scripts.find(
|
|
12
|
-
(item) => item.getAttribute("data-orello-react") === "true" && item.getAttribute("src") === scriptSrc
|
|
13
|
-
)) != null ? _a : null;
|
|
14
|
-
}
|
|
15
|
-
function OrelloWidget({
|
|
16
|
-
widgetKey,
|
|
17
|
-
assistantId,
|
|
18
|
-
scriptSrc = DEFAULT_SCRIPT_SRC,
|
|
19
|
-
apiBase,
|
|
20
|
-
agentEndpoint,
|
|
21
|
-
widgetUrl,
|
|
22
|
-
wakeWord = true,
|
|
23
|
-
onReady,
|
|
24
|
-
onError,
|
|
25
|
-
cleanupOnUnmount = false
|
|
26
|
-
}) {
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
if (!widgetKey || !widgetKey.trim()) {
|
|
32
|
-
console.error("[Orello React] Missing required prop: widgetKey");
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const handleReady = (event) => {
|
|
36
|
-
onReady == null ? void 0 : onReady(event);
|
|
37
|
-
};
|
|
38
|
-
const handleError = (event) => {
|
|
39
|
-
onError == null ? void 0 : onError(event);
|
|
40
|
-
};
|
|
41
|
-
window.addEventListener("orello:ready", handleReady);
|
|
42
|
-
window.addEventListener("orello:error", handleError);
|
|
43
|
-
const resolvedScriptSrc = scriptSrc.trim() || DEFAULT_SCRIPT_SRC;
|
|
44
|
-
const existingScript = getExistingScript(resolvedScriptSrc);
|
|
45
|
-
if (!existingScript) {
|
|
46
|
-
const script = document.createElement("script");
|
|
47
|
-
script.src = resolvedScriptSrc;
|
|
48
|
-
script.async = true;
|
|
49
|
-
script.setAttribute("data-orello-react", "true");
|
|
50
|
-
script.setAttribute("data-api-key", widgetKey);
|
|
51
|
-
script.setAttribute("data-key", widgetKey);
|
|
52
|
-
script.setAttribute("data-wake-word", wakeWord ? "true" : "false");
|
|
53
|
-
setOptionalAttribute(script, "data-agent-id", assistantId);
|
|
54
|
-
setOptionalAttribute(script, "data-api-base", apiBase);
|
|
55
|
-
setOptionalAttribute(script, "data-agent-endpoint", agentEndpoint);
|
|
56
|
-
setOptionalAttribute(script, "data-widget-url", widgetUrl);
|
|
57
|
-
document.head.appendChild(script);
|
|
58
|
-
return () => {
|
|
59
|
-
window.removeEventListener("orello:ready", handleReady);
|
|
60
|
-
window.removeEventListener("orello:error", handleError);
|
|
61
|
-
if (cleanupOnUnmount) {
|
|
62
|
-
const root = document.getElementById("orello-widget-root");
|
|
63
|
-
if (root) root.remove();
|
|
64
|
-
script.remove();
|
|
65
|
-
delete window.OrelloWidget;
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
existingScript.setAttribute("data-api-key", widgetKey);
|
|
70
|
-
existingScript.setAttribute("data-key", widgetKey);
|
|
71
|
-
existingScript.setAttribute("data-wake-word", wakeWord ? "true" : "false");
|
|
72
|
-
if (assistantId) {
|
|
73
|
-
existingScript.setAttribute("data-agent-id", assistantId);
|
|
74
|
-
}
|
|
75
|
-
if (apiBase) {
|
|
76
|
-
existingScript.setAttribute("data-api-base", apiBase);
|
|
77
|
-
}
|
|
78
|
-
if (agentEndpoint) {
|
|
79
|
-
existingScript.setAttribute("data-agent-endpoint", agentEndpoint);
|
|
80
|
-
}
|
|
81
|
-
if (widgetUrl) {
|
|
82
|
-
existingScript.setAttribute("data-widget-url", widgetUrl);
|
|
83
|
-
}
|
|
84
|
-
return () => {
|
|
85
|
-
window.removeEventListener("orello:ready", handleReady);
|
|
86
|
-
window.removeEventListener("orello:error", handleError);
|
|
87
|
-
if (cleanupOnUnmount) {
|
|
88
|
-
const root = document.getElementById("orello-widget-root");
|
|
89
|
-
if (root) root.remove();
|
|
90
|
-
existingScript.remove();
|
|
91
|
-
delete window.OrelloWidget;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}, [
|
|
95
|
-
widgetKey,
|
|
96
|
-
assistantId,
|
|
97
|
-
scriptSrc,
|
|
98
|
-
apiBase,
|
|
99
|
-
agentEndpoint,
|
|
100
|
-
widgetUrl,
|
|
101
|
-
wakeWord,
|
|
102
|
-
onReady,
|
|
103
|
-
onError,
|
|
104
|
-
cleanupOnUnmount
|
|
105
|
-
]);
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
export {
|
|
109
|
-
OrelloWidget
|
|
110
|
-
};
|
|
1
|
+
import{useEffect as h}from"react";import{jsx as k}from"react/jsx-runtime";var S="https://cdn.jsdelivr.net/npm/@orello/sdk@0.0.85/dist/orello.min.js";function d(i,l,t){t&&i.setAttribute(l,t)}function x(i){var t;return(t=Array.from(document.querySelectorAll("script[src]")).find(o=>o.getAttribute("data-orello-react")==="true"&&o.getAttribute("src")===i))!=null?t:null}function C({apiKey:i,widgetKey:l,assistantId:t,agent:o,scriptSrc:O=S,apiBase:a="https://api.ai.orello.space/api/v1",agentEndpoint:u="https://api.agent.orello.space",widgetUrl:c,wakeWord:v=!1,onReady:g,onError:p,onNavigate:f,cleanupOnUnmount:m=!1}){return h(()=>{if(typeof window=="undefined"||typeof document=="undefined")return;let n=i||l;if(!n||!n.trim()){console.error("[Orello React] Missing required prop: apiKey or widgetKey");return}let w=e=>{g==null||g(e)},A=e=>{p==null||p(e)},E=e=>{var L;let s=e;(L=s.detail)!=null&&L.url&&(e.preventDefault(),f&&f(s.detail.url))};window.addEventListener("orello:ready",w),window.addEventListener("orello:error",A),window.addEventListener("orello:navigate",E);let b=O.trim()||S,r=x(b),y=typeof o=="string"?o:o?JSON.stringify(o):void 0;if(!r){let e=document.createElement("script");return e.src=b,e.async=!0,e.setAttribute("data-orello-react","true"),e.setAttribute("data-api-key",n),e.setAttribute("data-key",n),e.setAttribute("data-wake-word",v?"true":"false"),d(e,"data-agent-id",t),d(e,"data-api-base",a),d(e,"data-agent-service-url",u),d(e,"data-widget-url",c),d(e,"data-agent",y),document.head.appendChild(e),()=>{if(window.removeEventListener("orello:ready",w),window.removeEventListener("orello:error",A),window.removeEventListener("orello:navigate",E),m){let s=document.getElementById("orello-widget-root");s&&s.remove(),e.remove(),delete window.OrelloWidget}}}return r.setAttribute("data-api-key",n),r.setAttribute("data-key",n),r.setAttribute("data-wake-word",v?"true":"false"),t&&r.setAttribute("data-agent-id",t),a&&r.setAttribute("data-api-base",a),u&&r.setAttribute("data-agent-service-url",u),c&&r.setAttribute("data-widget-url",c),y&&r.setAttribute("data-agent",y),()=>{if(window.removeEventListener("orello:ready",w),window.removeEventListener("orello:error",A),window.removeEventListener("orello:navigate",E),m){let e=document.getElementById("orello-widget-root");e&&e.remove(),r.remove(),delete window.OrelloWidget}}},[i,l,t,o,O,a,u,c,v,g,p,f,m]),k("div",{id:"orello-widget-host",style:{position:"fixed",zIndex:2147483e3}})}export{C as OrelloAgent};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orello/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "React wrapper for the Orello AI widget — embed intelligent conversational assistants into any React application.",
|
|
5
5
|
"author": "Orello Team <hello@orello.space>",
|
|
6
6
|
"license": "MIT",
|