zywlagent 0.1.7 → 0.1.8
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 -1
- package/dist/chunks/{index-GEwRc9yl.js → index-YBr9ETwH.js} +1583 -1563
- package/dist/gis-agent.js +50 -39
- package/package.json +1 -1
package/dist/gis-agent.js
CHANGED
|
@@ -1,73 +1,84 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
3
|
-
mapContainerId:
|
|
4
|
-
buttonId:
|
|
5
|
-
style:
|
|
6
|
-
onEvent:
|
|
7
|
-
platform:
|
|
1
|
+
const a = /* @__PURE__ */ new WeakMap();
|
|
2
|
+
function A({
|
|
3
|
+
mapContainerId: y = "myMap",
|
|
4
|
+
buttonId: f = `${y}-MapEngineAIAgent`,
|
|
5
|
+
style: w,
|
|
6
|
+
onEvent: E,
|
|
7
|
+
platform: h = {
|
|
8
8
|
baseUrl: "/platform"
|
|
9
9
|
},
|
|
10
|
-
GIS_AGENT_PLATFORM_URL:
|
|
11
|
-
|
|
10
|
+
GIS_AGENT_PLATFORM_URL: l,
|
|
11
|
+
accountId: i,
|
|
12
|
+
onError: g
|
|
12
13
|
} = {}) {
|
|
13
|
-
if (typeof
|
|
14
|
+
if (typeof f != "string" || !f.trim())
|
|
14
15
|
throw new TypeError("buttonId 必须是非空的元素 ID,不需要带 #。");
|
|
15
|
-
let
|
|
16
|
-
if (
|
|
16
|
+
let r;
|
|
17
|
+
if (i !== void 0) {
|
|
18
|
+
if (r = typeof i == "number" && Number.isSafeInteger(i) && i >= 0 ? String(i) : i, typeof r != "string" || !r || [...r].length > 128 || /\s|[\u0000-\u001f\u007f]/.test(r))
|
|
19
|
+
throw new TypeError("accountId 必须是 1 至 128 字符的稳定账号 ID,不允许空白字符。");
|
|
20
|
+
try {
|
|
21
|
+
encodeURIComponent(r);
|
|
22
|
+
} catch {
|
|
23
|
+
throw new TypeError("accountId 包含无法编码的字符。");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
let c = r === void 0 ? h : { ...h, accountId: r };
|
|
27
|
+
if (l !== void 0) {
|
|
17
28
|
let e;
|
|
18
29
|
try {
|
|
19
|
-
e = new URL(
|
|
30
|
+
e = new URL(l);
|
|
20
31
|
} catch {
|
|
21
32
|
throw new TypeError("GIS_AGENT_PLATFORM_URL 必须是完整服务地址,例如 http://服务器IP:8135。");
|
|
22
33
|
}
|
|
23
|
-
if (typeof
|
|
34
|
+
if (typeof l != "string" || !["http:", "https:"].includes(e.protocol) || e.username || e.password || e.search || e.hash || e.pathname.replace(/\/+$/, "") !== "")
|
|
24
35
|
throw new TypeError("GIS_AGENT_PLATFORM_URL 只填写 HTTP(S) 服务地址和端口,不要包含 /platform、查询参数或账号密码。");
|
|
25
|
-
|
|
36
|
+
c = { ...c, baseUrl: `${e.origin}/platform` };
|
|
26
37
|
}
|
|
27
|
-
let
|
|
28
|
-
const
|
|
38
|
+
let o = !1, u, t, s;
|
|
39
|
+
const p = (e = t) => {
|
|
29
40
|
if (!e) return;
|
|
30
|
-
const n =
|
|
31
|
-
n && (n.destroyed = !0, e.removeEventListener("click", n.onClick), n.handle && n.handle.destroy(),
|
|
32
|
-
},
|
|
33
|
-
if (
|
|
41
|
+
const n = a.get(e);
|
|
42
|
+
n && (n.destroyed = !0, e.removeEventListener("click", n.onClick), n.handle && n.handle.destroy(), a.delete(e)), e === t && (t = void 0, s = void 0);
|
|
43
|
+
}, C = (e) => {
|
|
44
|
+
if (o || !e || a.has(e)) return;
|
|
34
45
|
const n = {
|
|
35
46
|
destroyed: !1,
|
|
36
47
|
handle: void 0,
|
|
37
48
|
loading: void 0,
|
|
38
49
|
onClick: void 0
|
|
39
50
|
};
|
|
40
|
-
n.onClick = (
|
|
41
|
-
if (
|
|
51
|
+
n.onClick = (v) => {
|
|
52
|
+
if (v.stopPropagation(), !n.destroyed) {
|
|
42
53
|
if (n.handle) {
|
|
43
54
|
n.handle.toggle();
|
|
44
55
|
return;
|
|
45
56
|
}
|
|
46
|
-
n.loading || (n.loading = import("./chunks/index-
|
|
57
|
+
n.loading || (n.loading = import("./chunks/index-YBr9ETwH.js").then(({ mountAgentChat: d }) => {
|
|
47
58
|
if (!n.destroyed)
|
|
48
|
-
return n.handle =
|
|
59
|
+
return n.handle = d(document.body, {
|
|
49
60
|
anchorElement: e,
|
|
50
61
|
initialOpen: !0,
|
|
51
62
|
title: "智能助手",
|
|
52
|
-
onEvent:
|
|
53
|
-
platform:
|
|
54
|
-
style:
|
|
55
|
-
onError:
|
|
63
|
+
onEvent: E,
|
|
64
|
+
platform: c,
|
|
65
|
+
style: w,
|
|
66
|
+
onError: g
|
|
56
67
|
}), n.handle;
|
|
57
|
-
}).catch((
|
|
58
|
-
n.loading = void 0, console.error("智能体对话框加载失败。",
|
|
68
|
+
}).catch((d) => {
|
|
69
|
+
n.loading = void 0, console.error("智能体对话框加载失败。", d), g?.({ code: "AGENT_LOAD_FAILED", message: d instanceof Error ? d.message : String(d) });
|
|
59
70
|
}));
|
|
60
71
|
}
|
|
61
|
-
}, e.addEventListener("click", n.onClick),
|
|
62
|
-
},
|
|
63
|
-
if (
|
|
64
|
-
const e = document.getElementById(
|
|
65
|
-
e !== t && (t && !t.isConnected &&
|
|
72
|
+
}, e.addEventListener("click", n.onClick), a.set(e, n), t = e, s = n;
|
|
73
|
+
}, m = () => {
|
|
74
|
+
if (o) return;
|
|
75
|
+
const e = document.getElementById(f);
|
|
76
|
+
e !== t && (t && !t.isConnected && p(t), e && C(e)), t && !t.isConnected && p(t);
|
|
66
77
|
};
|
|
67
|
-
return
|
|
68
|
-
|
|
78
|
+
return m(), u = new MutationObserver(m), u.observe(document.body, { childList: !0, subtree: !0 }), () => {
|
|
79
|
+
o || (o = !0, u?.disconnect(), s && (s.destroyed = !0), p(t));
|
|
69
80
|
};
|
|
70
81
|
}
|
|
71
82
|
export {
|
|
72
|
-
|
|
83
|
+
A as mountCallerAgentChat
|
|
73
84
|
};
|