@release0/nextjs 0.2.3 → 0.3.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.
- package/README.md +2 -2
- package/dist/dist-4V5VSPZX.js +100 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +12 -18
- package/dist/web-53BLTPE3-WYQIGRDC.js +13467 -0
- package/package.json +7 -10
- package/dist/dist-WPLDFLQO.js +0 -56
package/README.md
CHANGED
|
@@ -120,7 +120,7 @@ toggle();
|
|
|
120
120
|
|
|
121
121
|
## Additional configuration
|
|
122
122
|
|
|
123
|
-
You can prefill the agent variable values in your embed code by adding the `
|
|
123
|
+
You can prefill the agent variable values in your embed code by adding the `initialContext` option. Here is an example:
|
|
124
124
|
|
|
125
125
|
```tsx
|
|
126
126
|
import { Standard } from "@release0/nextjs";
|
|
@@ -130,7 +130,7 @@ const App = () => {
|
|
|
130
130
|
<Standard
|
|
131
131
|
agent="ag_herexisxyourxagentxid"
|
|
132
132
|
style={{ width: "100%", height: "600px" }}
|
|
133
|
-
|
|
133
|
+
initialContext={{
|
|
134
134
|
"Account URL": "https://my-site.com/account",
|
|
135
135
|
"User name": "My username",
|
|
136
136
|
}}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
// ../react/dist/index.js
|
|
4
|
+
import { useEffect as l, useRef as c } from "react";
|
|
5
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
6
|
+
import { useCallback as d, useEffect as i, useRef as p } from "react";
|
|
7
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
8
|
+
import { useEffect as b, useRef as P } from "react";
|
|
9
|
+
import { jsx as M } from "react/jsx-runtime";
|
|
10
|
+
var w = ({ id: t } = {}) => {
|
|
11
|
+
let e = { isFromAgent: true, command: "close", id: t };
|
|
12
|
+
window.postMessage(e);
|
|
13
|
+
};
|
|
14
|
+
var v = ({ id: t } = {}) => {
|
|
15
|
+
let e = { isFromAgent: true, command: "open", id: t };
|
|
16
|
+
window.postMessage(e);
|
|
17
|
+
};
|
|
18
|
+
var R = (t, { id: e } = {}) => {
|
|
19
|
+
let n = { isFromAgent: true, command: "showPreviewMessage", message: t, id: e };
|
|
20
|
+
window.postMessage(n);
|
|
21
|
+
};
|
|
22
|
+
var T = ({ id: t } = {}) => {
|
|
23
|
+
let e = { isFromAgent: true, command: "toggle", id: t };
|
|
24
|
+
window.postMessage(e);
|
|
25
|
+
};
|
|
26
|
+
var H = ({ id: t } = {}) => {
|
|
27
|
+
let e = { isFromAgent: true, command: "reload", id: t };
|
|
28
|
+
window.postMessage(e);
|
|
29
|
+
};
|
|
30
|
+
var L = (t, { id: e } = {}) => {
|
|
31
|
+
let n = { isFromAgent: true, command: "setInputValue", value: t, id: e };
|
|
32
|
+
window.postMessage(n);
|
|
33
|
+
};
|
|
34
|
+
var y = ({ id: t } = {}) => {
|
|
35
|
+
let e = { isFromAgent: true, command: "unmount", id: t };
|
|
36
|
+
window.postMessage(e);
|
|
37
|
+
};
|
|
38
|
+
var A = (t, { id: e } = {}) => {
|
|
39
|
+
let n = { isFromAgent: true, command: "setPrefilledVariables", variables: t, id: e };
|
|
40
|
+
window.postMessage(n);
|
|
41
|
+
};
|
|
42
|
+
var h = ({ id: t } = {}) => {
|
|
43
|
+
let e = { isFromAgent: true, command: "hidePreviewMessage", id: t };
|
|
44
|
+
window.postMessage(e);
|
|
45
|
+
};
|
|
46
|
+
var m = (t) => {
|
|
47
|
+
let e = c(null);
|
|
48
|
+
return l(() => {
|
|
49
|
+
t.theme?.position !== "static" && (e.current || (e.current = document.createElement("agent-bubble"), document.body.prepend(e.current)), import("./web-53BLTPE3-WYQIGRDC.js").then(() => {
|
|
50
|
+
let { agent: n, ...r } = t;
|
|
51
|
+
Object.assign(e.current ?? document.createElement("agent-bubble"), r, { agent: n });
|
|
52
|
+
}));
|
|
53
|
+
}, [t]), l(() => () => {
|
|
54
|
+
t.theme?.position !== "static" && (e.current?.remove(), e.current = null);
|
|
55
|
+
}, [t.theme?.position]), t.theme?.position === "static" ? u("agent-bubble", { ref: e, style: { display: "inline-flex" } }) : null;
|
|
56
|
+
};
|
|
57
|
+
var g = (t) => {
|
|
58
|
+
let e = p(null), n = p(null), r = d((s) => {
|
|
59
|
+
let a = document.createElement("agent-popup");
|
|
60
|
+
if (n.current = a, o(n.current, s), !e.current) {
|
|
61
|
+
console.warn("Could not attach popup to container because containerRef.current is null");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
e.current?.append(n.current);
|
|
65
|
+
}, []);
|
|
66
|
+
i(() => {
|
|
67
|
+
n.current || r(t), o(n.current, t);
|
|
68
|
+
}, [r, t]), i(() => () => {
|
|
69
|
+
n.current?.remove(), n.current = null;
|
|
70
|
+
}, []);
|
|
71
|
+
let o = (s, a) => {
|
|
72
|
+
import("./web-53BLTPE3-WYQIGRDC.js").then(() => {
|
|
73
|
+
Object.assign(s, a);
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
return f("div", { ref: e });
|
|
77
|
+
};
|
|
78
|
+
var E = ({ style: t, className: e, ...n }) => {
|
|
79
|
+
let r = P(null);
|
|
80
|
+
return b(() => {
|
|
81
|
+
import("./web-53BLTPE3-WYQIGRDC.js").then(() => {
|
|
82
|
+
let { agent: o, ...s } = n;
|
|
83
|
+
Object.assign(r.current, s, { agent: o });
|
|
84
|
+
});
|
|
85
|
+
}, [n]), M("agent-standard", { ref: r, style: t, class: e });
|
|
86
|
+
};
|
|
87
|
+
export {
|
|
88
|
+
m as Bubble,
|
|
89
|
+
g as Popup,
|
|
90
|
+
E as Standard,
|
|
91
|
+
w as close,
|
|
92
|
+
h as hidePreviewMessage,
|
|
93
|
+
v as open,
|
|
94
|
+
H as reload,
|
|
95
|
+
L as setInputValue,
|
|
96
|
+
A as setPrefilledVariables,
|
|
97
|
+
R as showPreviewMessage,
|
|
98
|
+
T as toggle,
|
|
99
|
+
y as unmount
|
|
100
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export { close, hidePreviewMessage, open, setInputValue, setPrefilledVariables,
|
|
|
5
5
|
declare const Standard: react.ComponentType<_release0_js.AgentProps & {
|
|
6
6
|
style?: React.CSSProperties;
|
|
7
7
|
className?: string;
|
|
8
|
-
}
|
|
9
|
-
declare const Bubble: react.ComponentType<_release0_js.BubbleProps
|
|
10
|
-
declare const Popup: react.ComponentType<_release0_js.PopupProps
|
|
8
|
+
}> | (() => null);
|
|
9
|
+
declare const Bubble: react.ComponentType<_release0_js.BubbleProps> | (() => null);
|
|
10
|
+
declare const Popup: react.ComponentType<_release0_js.PopupProps> | (() => null);
|
|
11
11
|
|
|
12
12
|
export { Bubble, Popup, Standard };
|
package/dist/index.js
CHANGED
|
@@ -12,24 +12,18 @@ import {
|
|
|
12
12
|
hidePreviewMessage,
|
|
13
13
|
close
|
|
14
14
|
} from "@release0/js";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
);
|
|
21
|
-
var Bubble = dynamic(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
);
|
|
27
|
-
var Popup = dynamic(
|
|
28
|
-
() => import("./dist-WPLDFLQO.js").then((mod) => mod.Popup),
|
|
29
|
-
{
|
|
30
|
-
ssr: false
|
|
31
|
-
}
|
|
32
|
-
);
|
|
15
|
+
function isClient() {
|
|
16
|
+
return typeof window !== "undefined";
|
|
17
|
+
}
|
|
18
|
+
var Standard = isClient() ? dynamic(() => import("./dist-4V5VSPZX.js").then((mod) => mod.Standard), {
|
|
19
|
+
ssr: false
|
|
20
|
+
}) : () => null;
|
|
21
|
+
var Bubble = isClient() ? dynamic(() => import("./dist-4V5VSPZX.js").then((mod) => mod.Bubble), {
|
|
22
|
+
ssr: false
|
|
23
|
+
}) : () => null;
|
|
24
|
+
var Popup = isClient() ? dynamic(() => import("./dist-4V5VSPZX.js").then((mod) => mod.Popup), {
|
|
25
|
+
ssr: false
|
|
26
|
+
}) : () => null;
|
|
33
27
|
export {
|
|
34
28
|
Bubble,
|
|
35
29
|
Popup,
|