site-operator-react 0.2.8 → 0.2.9
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.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { ChatController } from 'site-operator';
|
|
|
7
7
|
import { ClickTarget } from 'site-operator';
|
|
8
8
|
import { default as default_2 } from 'react';
|
|
9
9
|
import { ExecutePlanResult } from 'site-operator';
|
|
10
|
-
import { RefObject } from 'react';
|
|
11
10
|
import { SuggestedPrompt } from 'site-operator';
|
|
12
11
|
|
|
13
12
|
export declare const AgentChat: default_2.ForwardRefExoticComponent<AgentChatProps & default_2.RefAttributes<AgentChat_2>>;
|
|
@@ -74,8 +73,8 @@ export declare function useAgentChatController(): ChatController | null;
|
|
|
74
73
|
* This allows the agent to navigate and control the host application.
|
|
75
74
|
* @param context The AppContext defining site, user and navigation.
|
|
76
75
|
* If null/undefined, registration is skipped.
|
|
77
|
-
* @param options Optional
|
|
78
|
-
* @returns ChatController instance if an AgentChat
|
|
76
|
+
* @param options Optional options for accessing the AgentChat controller and custom handlers.
|
|
77
|
+
* @returns ChatController instance if an AgentChat element is provided.
|
|
79
78
|
*/
|
|
80
79
|
export declare function useChatPortal(context: AppContext | null | undefined, options?: UseChatPortalOptions & {
|
|
81
80
|
handlers?: {
|
|
@@ -84,7 +83,7 @@ export declare function useChatPortal(context: AppContext | null | undefined, op
|
|
|
84
83
|
}): ChatController | null;
|
|
85
84
|
|
|
86
85
|
export declare type UseChatPortalOptions = {
|
|
87
|
-
|
|
86
|
+
element?: AgentChat_2 | null;
|
|
88
87
|
};
|
|
89
88
|
|
|
90
89
|
export { }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import q, { useRef as
|
|
1
|
+
import q, { useRef as J, useImperativeHandle as ie, useEffect as b, useState as N, createContext as V, useContext as z } from "react";
|
|
2
2
|
import { chatPortalService as ce } from "site-operator";
|
|
3
3
|
import { createPortal as fe } from "react-dom";
|
|
4
4
|
var S = { exports: {} }, T = {};
|
|
@@ -16,18 +16,18 @@ function de() {
|
|
|
16
16
|
if (L) return T;
|
|
17
17
|
L = 1;
|
|
18
18
|
var s = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
|
|
19
|
-
function f(d,
|
|
20
|
-
var
|
|
21
|
-
if (i !== void 0 && (
|
|
19
|
+
function f(d, l, i) {
|
|
20
|
+
var m = null;
|
|
21
|
+
if (i !== void 0 && (m = "" + i), l.key !== void 0 && (m = "" + l.key), "key" in l) {
|
|
22
22
|
i = {};
|
|
23
|
-
for (var n in
|
|
24
|
-
n !== "key" && (i[n] =
|
|
25
|
-
} else i =
|
|
26
|
-
return
|
|
23
|
+
for (var n in l)
|
|
24
|
+
n !== "key" && (i[n] = l[n]);
|
|
25
|
+
} else i = l;
|
|
26
|
+
return l = i.ref, {
|
|
27
27
|
$$typeof: s,
|
|
28
28
|
type: d,
|
|
29
|
-
key:
|
|
30
|
-
ref:
|
|
29
|
+
key: m,
|
|
30
|
+
ref: l !== void 0 ? l : null,
|
|
31
31
|
props: i
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -44,7 +44,7 @@ var p = {};
|
|
|
44
44
|
* LICENSE file in the root directory of this source tree.
|
|
45
45
|
*/
|
|
46
46
|
var W;
|
|
47
|
-
function
|
|
47
|
+
function me() {
|
|
48
48
|
return W || (W = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
49
49
|
function s(e) {
|
|
50
50
|
if (e == null) return null;
|
|
@@ -80,7 +80,7 @@ function Ee() {
|
|
|
80
80
|
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
81
81
|
case ae:
|
|
82
82
|
return r = e.displayName || null, r !== null ? r : s(e.type) || "Memo";
|
|
83
|
-
case
|
|
83
|
+
case y:
|
|
84
84
|
r = e._payload, e = e._init;
|
|
85
85
|
try {
|
|
86
86
|
return s(e(r));
|
|
@@ -101,8 +101,8 @@ function Ee() {
|
|
|
101
101
|
}
|
|
102
102
|
if (r) {
|
|
103
103
|
r = console;
|
|
104
|
-
var
|
|
105
|
-
return
|
|
104
|
+
var a = r.error, u = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
105
|
+
return a.call(
|
|
106
106
|
r,
|
|
107
107
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
108
108
|
u
|
|
@@ -111,7 +111,7 @@ function Ee() {
|
|
|
111
111
|
}
|
|
112
112
|
function d(e) {
|
|
113
113
|
if (e === C) return "<>";
|
|
114
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
114
|
+
if (typeof e == "object" && e !== null && e.$$typeof === y)
|
|
115
115
|
return "<...>";
|
|
116
116
|
try {
|
|
117
117
|
var r = s(e);
|
|
@@ -120,14 +120,14 @@ function Ee() {
|
|
|
120
120
|
return "<...>";
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
var e =
|
|
123
|
+
function l() {
|
|
124
|
+
var e = O.A;
|
|
125
125
|
return e === null ? null : e.getOwner();
|
|
126
126
|
}
|
|
127
127
|
function i() {
|
|
128
128
|
return Error("react-stack-top-frame");
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function m(e) {
|
|
131
131
|
if (Y.call(e, "key")) {
|
|
132
132
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
133
133
|
if (r && r.isReactWarning) return !1;
|
|
@@ -135,34 +135,34 @@ function Ee() {
|
|
|
135
135
|
return e.key !== void 0;
|
|
136
136
|
}
|
|
137
137
|
function n(e, r) {
|
|
138
|
-
function
|
|
138
|
+
function a() {
|
|
139
139
|
$ || ($ = !0, console.error(
|
|
140
140
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
141
141
|
r
|
|
142
142
|
));
|
|
143
143
|
}
|
|
144
|
-
|
|
145
|
-
get:
|
|
144
|
+
a.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
145
|
+
get: a,
|
|
146
146
|
configurable: !0
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function _() {
|
|
150
150
|
var e = s(this.type);
|
|
151
151
|
return I[e] || (I[e] = !0, console.error(
|
|
152
152
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
153
153
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
154
154
|
}
|
|
155
|
-
function v(e, r,
|
|
156
|
-
var o =
|
|
155
|
+
function v(e, r, a, u, k, j) {
|
|
156
|
+
var o = a.ref;
|
|
157
157
|
return e = {
|
|
158
158
|
$$typeof: x,
|
|
159
159
|
type: e,
|
|
160
160
|
key: r,
|
|
161
|
-
props:
|
|
161
|
+
props: a,
|
|
162
162
|
_owner: u
|
|
163
163
|
}, (o !== void 0 ? o : null) !== null ? Object.defineProperty(e, "ref", {
|
|
164
164
|
enumerable: !1,
|
|
165
|
-
get:
|
|
165
|
+
get: _
|
|
166
166
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
167
167
|
configurable: !1,
|
|
168
168
|
enumerable: !1,
|
|
@@ -185,7 +185,7 @@ function Ee() {
|
|
|
185
185
|
value: j
|
|
186
186
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
187
187
|
}
|
|
188
|
-
function c(e, r,
|
|
188
|
+
function c(e, r, a, u, k, j) {
|
|
189
189
|
var o = r.children;
|
|
190
190
|
if (o !== void 0)
|
|
191
191
|
if (u)
|
|
@@ -200,10 +200,10 @@ function Ee() {
|
|
|
200
200
|
else A(o);
|
|
201
201
|
if (Y.call(r, "key")) {
|
|
202
202
|
o = s(e);
|
|
203
|
-
var
|
|
203
|
+
var R = Object.keys(r).filter(function(se) {
|
|
204
204
|
return se !== "key";
|
|
205
205
|
});
|
|
206
|
-
u = 0 <
|
|
206
|
+
u = 0 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}", D[o + u] || (R = 0 < R.length ? "{" + R.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
207
207
|
`A props object containing a "key" prop is being spread into JSX:
|
|
208
208
|
let props = %s;
|
|
209
209
|
<%s {...props} />
|
|
@@ -212,34 +212,34 @@ React keys must be passed directly to JSX without using spread:
|
|
|
212
212
|
<%s key={someKey} {...props} />`,
|
|
213
213
|
u,
|
|
214
214
|
o,
|
|
215
|
-
|
|
215
|
+
R,
|
|
216
216
|
o
|
|
217
217
|
), D[o + u] = !0);
|
|
218
218
|
}
|
|
219
|
-
if (o = null,
|
|
220
|
-
|
|
219
|
+
if (o = null, a !== void 0 && (f(a), o = "" + a), m(r) && (f(r.key), o = "" + r.key), "key" in r) {
|
|
220
|
+
a = {};
|
|
221
221
|
for (var w in r)
|
|
222
|
-
w !== "key" && (
|
|
223
|
-
} else
|
|
222
|
+
w !== "key" && (a[w] = r[w]);
|
|
223
|
+
} else a = r;
|
|
224
224
|
return o && n(
|
|
225
|
-
|
|
225
|
+
a,
|
|
226
226
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
227
227
|
), v(
|
|
228
228
|
e,
|
|
229
229
|
o,
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
a,
|
|
231
|
+
l(),
|
|
232
232
|
k,
|
|
233
233
|
j
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
236
|
function A(e) {
|
|
237
|
-
|
|
237
|
+
E(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === y && (e._payload.status === "fulfilled" ? E(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function E(e) {
|
|
240
240
|
return typeof e == "object" && e !== null && e.$$typeof === x;
|
|
241
241
|
}
|
|
242
|
-
var P = q, x = Symbol.for("react.transitional.element"), B = Symbol.for("react.portal"), C = Symbol.for("react.fragment"), Z = Symbol.for("react.strict_mode"), Q = Symbol.for("react.profiler"), K = Symbol.for("react.consumer"), ee = Symbol.for("react.context"), re = Symbol.for("react.forward_ref"), te = Symbol.for("react.suspense"), ne = Symbol.for("react.suspense_list"), ae = Symbol.for("react.memo"),
|
|
242
|
+
var P = q, x = Symbol.for("react.transitional.element"), B = Symbol.for("react.portal"), C = Symbol.for("react.fragment"), Z = Symbol.for("react.strict_mode"), Q = Symbol.for("react.profiler"), K = Symbol.for("react.consumer"), ee = Symbol.for("react.context"), re = Symbol.for("react.forward_ref"), te = Symbol.for("react.suspense"), ne = Symbol.for("react.suspense_list"), ae = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), le = Symbol.for("react.activity"), ue = Symbol.for("react.client.reference"), O = P.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Y = Object.prototype.hasOwnProperty, oe = Array.isArray, h = console.createTask ? console.createTask : function() {
|
|
243
243
|
return null;
|
|
244
244
|
};
|
|
245
245
|
P = {
|
|
@@ -250,102 +250,101 @@ React keys must be passed directly to JSX without using spread:
|
|
|
250
250
|
var $, I = {}, M = P.react_stack_bottom_frame.bind(
|
|
251
251
|
P,
|
|
252
252
|
i
|
|
253
|
-
)(), F =
|
|
254
|
-
p.Fragment = C, p.jsx = function(e, r,
|
|
255
|
-
var u = 1e4 >
|
|
253
|
+
)(), F = h(d(i)), D = {};
|
|
254
|
+
p.Fragment = C, p.jsx = function(e, r, a) {
|
|
255
|
+
var u = 1e4 > O.recentlyCreatedOwnerStacks++;
|
|
256
256
|
return c(
|
|
257
257
|
e,
|
|
258
258
|
r,
|
|
259
|
-
|
|
259
|
+
a,
|
|
260
260
|
!1,
|
|
261
261
|
u ? Error("react-stack-top-frame") : M,
|
|
262
|
-
u ?
|
|
262
|
+
u ? h(d(e)) : F
|
|
263
263
|
);
|
|
264
|
-
}, p.jsxs = function(e, r,
|
|
265
|
-
var u = 1e4 >
|
|
264
|
+
}, p.jsxs = function(e, r, a) {
|
|
265
|
+
var u = 1e4 > O.recentlyCreatedOwnerStacks++;
|
|
266
266
|
return c(
|
|
267
267
|
e,
|
|
268
268
|
r,
|
|
269
|
-
|
|
269
|
+
a,
|
|
270
270
|
!0,
|
|
271
271
|
u ? Error("react-stack-top-frame") : M,
|
|
272
|
-
u ?
|
|
272
|
+
u ? h(d(e)) : F
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
275
|
})()), p;
|
|
276
276
|
}
|
|
277
277
|
var U;
|
|
278
|
-
function
|
|
279
|
-
return U || (U = 1, process.env.NODE_ENV === "production" ? S.exports = de() : S.exports =
|
|
278
|
+
function Ee() {
|
|
279
|
+
return U || (U = 1, process.env.NODE_ENV === "production" ? S.exports = de() : S.exports = me()), S.exports;
|
|
280
280
|
}
|
|
281
|
-
var g =
|
|
281
|
+
var g = Ee();
|
|
282
282
|
const G = q.forwardRef(({
|
|
283
283
|
backendUrl: s,
|
|
284
284
|
conversationUrl: t,
|
|
285
285
|
appName: f,
|
|
286
286
|
agentAvatar: d,
|
|
287
|
-
inspector:
|
|
287
|
+
inspector: l,
|
|
288
288
|
interceptor: i,
|
|
289
|
-
className:
|
|
289
|
+
className: m,
|
|
290
290
|
composer: n,
|
|
291
|
-
thread:
|
|
291
|
+
thread: _,
|
|
292
292
|
header: v,
|
|
293
293
|
context: c
|
|
294
294
|
}, A) => {
|
|
295
|
-
const
|
|
296
|
-
return ie(A, () =>
|
|
297
|
-
|
|
298
|
-
}, [c == null ? void 0 : c.appContext]),
|
|
299
|
-
|
|
300
|
-
}, [c == null ? void 0 : c.appState]),
|
|
301
|
-
|
|
295
|
+
const E = J(null);
|
|
296
|
+
return ie(A, () => E.current), b(() => {
|
|
297
|
+
E.current && (c != null && c.appContext) && E.current.setAppContext(c.appContext);
|
|
298
|
+
}, [c == null ? void 0 : c.appContext]), b(() => {
|
|
299
|
+
E.current && (c != null && c.appState) && E.current.setAppState(c.appState);
|
|
300
|
+
}, [c == null ? void 0 : c.appState]), b(() => {
|
|
301
|
+
E.current && (n != null && n.suggestedPrompts) && E.current.setSuggestedPrompts(n.suggestedPrompts);
|
|
302
302
|
}, [n == null ? void 0 : n.suggestedPrompts]), /* @__PURE__ */ g.jsx(
|
|
303
303
|
"agent-chat",
|
|
304
304
|
{
|
|
305
|
-
ref:
|
|
305
|
+
ref: E,
|
|
306
306
|
backendUrl: s,
|
|
307
307
|
conversationUrl: t,
|
|
308
308
|
appName: f,
|
|
309
309
|
agentAvatar: d,
|
|
310
310
|
disclaimer: n == null ? void 0 : n.disclaimer,
|
|
311
311
|
placeholder: n == null ? void 0 : n.placeholder,
|
|
312
|
-
emptyText:
|
|
312
|
+
emptyText: _ == null ? void 0 : _.emptyText,
|
|
313
313
|
headerTitle: v == null ? void 0 : v.title,
|
|
314
314
|
hideHeader: v == null ? void 0 : v.hide,
|
|
315
|
-
inspector:
|
|
315
|
+
inspector: l ? "true" : void 0,
|
|
316
316
|
interceptor: i ? !0 : void 0,
|
|
317
|
-
class:
|
|
317
|
+
class: m
|
|
318
318
|
}
|
|
319
319
|
);
|
|
320
320
|
});
|
|
321
321
|
G.displayName = "AgentChat";
|
|
322
322
|
function ve(s, t) {
|
|
323
|
-
const [f, d] =
|
|
324
|
-
return
|
|
323
|
+
const [f, d] = N(null);
|
|
324
|
+
return b(() => {
|
|
325
325
|
s && ce.registerPortal(s, t == null ? void 0 : t.handlers);
|
|
326
|
-
}, [s, t == null ? void 0 : t.handlers]),
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
if (a.controller) {
|
|
331
|
-
d(a.controller);
|
|
326
|
+
}, [s, t == null ? void 0 : t.handlers]), b(() => {
|
|
327
|
+
const l = t == null ? void 0 : t.element;
|
|
328
|
+
if (!l) {
|
|
329
|
+
d(null);
|
|
332
330
|
return;
|
|
333
331
|
}
|
|
334
|
-
|
|
335
|
-
|
|
332
|
+
l.controller && d(l.controller);
|
|
333
|
+
const i = (m) => {
|
|
334
|
+
d(m.detail ?? null);
|
|
336
335
|
};
|
|
337
|
-
return
|
|
338
|
-
|
|
336
|
+
return l.addEventListener("controller-ready", i), () => {
|
|
337
|
+
l.removeEventListener("controller-ready", i);
|
|
339
338
|
};
|
|
340
|
-
}, [t == null ? void 0 : t.
|
|
339
|
+
}, [t == null ? void 0 : t.element]), f;
|
|
341
340
|
}
|
|
342
341
|
const X = V(null), H = V(null);
|
|
343
342
|
function Te() {
|
|
344
343
|
return z(X);
|
|
345
344
|
}
|
|
346
345
|
const pe = ({ children: s, ...t }) => {
|
|
347
|
-
const f = z(H), d =
|
|
348
|
-
return
|
|
346
|
+
const f = z(H), d = J(null);
|
|
347
|
+
return b(() => {
|
|
349
348
|
if (f)
|
|
350
349
|
return f(d.current), () => {
|
|
351
350
|
f(null);
|
|
@@ -357,10 +356,10 @@ const pe = ({ children: s, ...t }) => {
|
|
|
357
356
|
handlers: f,
|
|
358
357
|
...d
|
|
359
358
|
}) => {
|
|
360
|
-
const
|
|
361
|
-
return /* @__PURE__ */ g.jsx(X.Provider, { value:
|
|
359
|
+
const [l, i] = N(null), m = ve(t == null ? void 0 : t.appContext, { element: l, handlers: f }), [n, _] = N(null);
|
|
360
|
+
return /* @__PURE__ */ g.jsx(X.Provider, { value: m, children: /* @__PURE__ */ g.jsxs(H.Provider, { value: _, children: [
|
|
362
361
|
s,
|
|
363
|
-
|
|
362
|
+
n ? fe(/* @__PURE__ */ g.jsx(G, { ref: i, context: t, ...d }), n) : null
|
|
364
363
|
] }) });
|
|
365
364
|
};
|
|
366
365
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(m,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react"),require("site-operator"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","site-operator","react-dom"],n):(m=typeof globalThis<"u"?globalThis:m||self,n(m.SiteOperatorReact={},m.React,m.SiteOperator,m.ReactDOM))})(this,(function(m,n,H,B){"use strict";var C={exports:{}},p={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Y;function Z(){if(Y)return
|
|
9
|
+
*/var Y;function Z(){if(Y)return p;Y=1;var c=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function d(E,u,i){var v=null;if(i!==void 0&&(v=""+i),u.key!==void 0&&(v=""+u.key),"key"in u){i={};for(var a in u)a!=="key"&&(i[a]=u[a])}else i=u;return u=i.ref,{$$typeof:c,type:E,key:v,ref:u!==void 0?u:null,props:i}}return p.Fragment=t,p.jsx=d,p.jsxs=d,p}var g={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var M;function Q(){return M||(M=1,process.env.NODE_ENV!=="production"&&(function(){function c(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===
|
|
17
|
+
*/var M;function Q(){return M||(M=1,process.env.NODE_ENV!=="production"&&(function(){function c(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case y:return"Fragment";case ne:return"Profiler";case te:return"StrictMode";case se:return"Suspense";case oe:return"SuspenseList";case ie:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case re:return"Portal";case le:return e.displayName||"Context";case ae:return(e._context.displayName||"Context")+".Consumer";case ue:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ce:return r=e.displayName||null,r!==null?r:c(e.type)||"Memo";case O:r=e._payload,e=e._init;try{return c(e(r))}catch{}}return null}function t(e){return""+e}function d(e){try{t(e);var r=!1}catch{r=!0}if(r){r=console;var l=r.error,s=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return l.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",s),t(e)}}function E(e){if(e===y)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===O)return"<...>";try{var r=c(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function u(){var e=j.A;return e===null?null:e.getOwner()}function i(){return Error("react-stack-top-frame")}function v(e){if(U.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function a(e,r){function l(){J||(J=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}l.isReactWarning=!0,Object.defineProperty(e,"key",{get:l,configurable:!0})}function T(){var e=c(this.type);return V[e]||(V[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function R(e,r,l,s,h,N){var o=l.ref;return e={$$typeof:W,type:e,key:r,props:l,_owner:s},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:T}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:h}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:N}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function f(e,r,l,s,h,N){var o=r.children;if(o!==void 0)if(s)if(de(o)){for(s=0;s<o.length;s++)P(o[s]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else P(o);if(U.call(r,"key")){o=c(e);var b=Object.keys(r).filter(function(Ee){return Ee!=="key"});s=0<b.length?"{key: someKey, "+b.join(": ..., ")+": ...}":"{key: someKey}",X[o+s]||(b=0<b.length?"{"+b.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,s,o,
|
|
22
|
+
<%s key={someKey} {...props} />`,s,o,b,o),X[o+s]=!0)}if(o=null,l!==void 0&&(d(l),o=""+l),v(r)&&(d(r.key),o=""+r.key),"key"in r){l={};for(var x in r)x!=="key"&&(l[x]=r[x])}else l=r;return o&&a(l,typeof e=="function"?e.displayName||e.name||"Unknown":e),R(e,o,l,u(),h,N)}function P(e){_(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===O&&(e._payload.status==="fulfilled"?_(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function _(e){return typeof e=="object"&&e!==null&&e.$$typeof===W}var S=n,W=Symbol.for("react.transitional.element"),re=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),te=Symbol.for("react.strict_mode"),ne=Symbol.for("react.profiler"),ae=Symbol.for("react.consumer"),le=Symbol.for("react.context"),ue=Symbol.for("react.forward_ref"),se=Symbol.for("react.suspense"),oe=Symbol.for("react.suspense_list"),ce=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),ie=Symbol.for("react.activity"),fe=Symbol.for("react.client.reference"),j=S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=Object.prototype.hasOwnProperty,de=Array.isArray,w=console.createTask?console.createTask:function(){return null};S={react_stack_bottom_frame:function(e){return e()}};var J,V={},z=S.react_stack_bottom_frame.bind(S,i)(),G=w(E(i)),X={};g.Fragment=y,g.jsx=function(e,r,l){var s=1e4>j.recentlyCreatedOwnerStacks++;return f(e,r,l,!1,s?Error("react-stack-top-frame"):z,s?w(E(e)):G)},g.jsxs=function(e,r,l){var s=1e4>j.recentlyCreatedOwnerStacks++;return f(e,r,l,!0,s?Error("react-stack-top-frame"):z,s?w(E(e)):G)}})()),g}var I;function K(){return I||(I=1,process.env.NODE_ENV==="production"?C.exports=Z():C.exports=Q()),C.exports}var A=K();const k=n.forwardRef(({backendUrl:c,conversationUrl:t,appName:d,agentAvatar:E,inspector:u,interceptor:i,className:v,composer:a,thread:T,header:R,context:f},P)=>{const _=n.useRef(null);return n.useImperativeHandle(P,()=>_.current),n.useEffect(()=>{_.current&&(f!=null&&f.appContext)&&_.current.setAppContext(f.appContext)},[f==null?void 0:f.appContext]),n.useEffect(()=>{_.current&&(f!=null&&f.appState)&&_.current.setAppState(f.appState)},[f==null?void 0:f.appState]),n.useEffect(()=>{_.current&&(a!=null&&a.suggestedPrompts)&&_.current.setSuggestedPrompts(a.suggestedPrompts)},[a==null?void 0:a.suggestedPrompts]),A.jsx("agent-chat",{ref:_,backendUrl:c,conversationUrl:t,appName:d,agentAvatar:E,disclaimer:a==null?void 0:a.disclaimer,placeholder:a==null?void 0:a.placeholder,emptyText:T==null?void 0:T.emptyText,headerTitle:R==null?void 0:R.title,hideHeader:R==null?void 0:R.hide,inspector:u?"true":void 0,interceptor:i?!0:void 0,class:v})});k.displayName="AgentChat";function D(c,t){const[d,E]=n.useState(null);return n.useEffect(()=>{c&&H.chatPortalService.registerPortal(c,t==null?void 0:t.handlers)},[c,t==null?void 0:t.handlers]),n.useEffect(()=>{const u=t==null?void 0:t.element;if(!u){E(null);return}u.controller&&E(u.controller);const i=v=>{E(v.detail??null)};return u.addEventListener("controller-ready",i),()=>{u.removeEventListener("controller-ready",i)}},[t==null?void 0:t.element]),d}const F=n.createContext(null),L=n.createContext(null);function q(){return n.useContext(F)}const $=({children:c,...t})=>{const d=n.useContext(L),E=n.useRef(null);return n.useEffect(()=>{if(d)return d(E.current),()=>{d(null)}},[d]),A.jsx("div",{ref:E,...t,children:c})},ee=({children:c,context:t,handlers:d,...E})=>{const[u,i]=n.useState(null),v=D(t==null?void 0:t.appContext,{element:u,handlers:d}),[a,T]=n.useState(null);return A.jsx(F.Provider,{value:v,children:A.jsxs(L.Provider,{value:T,children:[c,a?B.createPortal(A.jsx(k,{ref:i,context:t,...E}),a):null]})})};m.AgentChat=k,m.AgentChatMount=$,m.AgentChatProvider=ee,m.useAgentChatController=q,m.useChatPortal=D,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "site-operator-react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "React wrapper for site-operator, providing AgentChat component and hooks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "jostvian",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dev": "vite build --watch"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"site-operator": "^0.
|
|
35
|
+
"site-operator": "^0.3.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": "^19.0.0",
|
|
@@ -47,4 +47,4 @@
|
|
|
47
47
|
"vite": "^6.0.0",
|
|
48
48
|
"vite-plugin-dts": "^4.5.0"
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|