dsh-dock 0.25.0 → 0.26.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 +13 -5
- package/client.js +1576 -130
- package/features/dshtools/host.js +2 -1
- package/features/git/host.js +551 -16
- package/features/git/rpc.js +13 -1
- package/features/git/view.jsx +1782 -54
- package/package.json +1 -1
- package/src/client.jsx +5 -3
- package/src/host-core.js +13 -0
package/features/git/rpc.js
CHANGED
|
@@ -6,10 +6,22 @@
|
|
|
6
6
|
|
|
7
7
|
/** 调一条 git 路由;失败时抛带宿主错误说明的 Error。 */
|
|
8
8
|
export async function rpc(method, body) {
|
|
9
|
+
// 序列化放在前面单独做:请求体里混进 DOM 事件这类对象时,
|
|
10
|
+
// JSON.stringify 会抛「Converting circular structure to JSON」,
|
|
11
|
+
// 那个堆栈对使用者毫无意义(只看到一堆 _reactFiber 字段)。
|
|
12
|
+
// 这里换成一句能直接指向病因的提示。
|
|
13
|
+
let payload;
|
|
14
|
+
if (body !== undefined) {
|
|
15
|
+
try {
|
|
16
|
+
payload = JSON.stringify(body);
|
|
17
|
+
} catch {
|
|
18
|
+
throw new Error("请求体无法序列化:" + method + " 的参数里混进了 DOM 事件或循环引用对象(检查事件处理函数是否把 event 直接传了进来)");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
9
21
|
const res = await fetch("dsh-dock/git/" + method, {
|
|
10
22
|
method: body === undefined ? "GET" : "POST",
|
|
11
23
|
headers: body === undefined ? undefined : { "content-type": "application/json" },
|
|
12
|
-
body:
|
|
24
|
+
body: payload,
|
|
13
25
|
});
|
|
14
26
|
const data = await res.json().catch(() => ({}));
|
|
15
27
|
if (res.ok && data && data.ok === true) return data.data;
|