cortico-world-hands 0.20.41 → 0.20.43

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1457,7 +1457,7 @@ var Hands = class {
1457
1457
  return res.body.toString("utf8");
1458
1458
  }
1459
1459
  /** 画板:新开一张。 */
1460
- async canvasNew(w = 512, h = 512, bg = "transparent") {
1460
+ async canvasNew(w = 768, h = 768, bg = "transparent") {
1461
1461
  const cfg = this.cfg();
1462
1462
  const credential = this.readToken();
1463
1463
  const t = credential ? `&t=${encodeURIComponent(credential)}` : "";
@@ -1465,29 +1465,31 @@ var Hands = class {
1465
1465
  return res.body.toString("utf8");
1466
1466
  }
1467
1467
  /** 画板:画一笔。 */
1468
- async canvasStroke(points, color = "#111111", width = 4, tool = "pen") {
1468
+ async canvasStroke(points, color = "#111111", width = 2, tool = "pen") {
1469
1469
  const cfg = this.cfg();
1470
1470
  const credential = this.readToken();
1471
1471
  const t = credential ? `t=${encodeURIComponent(credential)}` : "";
1472
- const body = JSON.stringify({ points, color, width });
1472
+ const body = JSON.stringify({ points, color, width, tool });
1473
1473
  const res = await post(this.port(cfg.handPort), `/canvas/stroke?${t}`, body, ACTION_TIMEOUT_MS);
1474
1474
  return res.body.toString("utf8");
1475
1475
  }
1476
1476
  /** 画板:油漆桶填充。 */
1477
1477
  async canvasFill(x, y, color = "#6BFFB0") {
1478
1478
  const cfg = this.cfg();
1479
- const t = cfg.token ? `t=${encodeURIComponent(cfg.token)}` : "";
1479
+ const credential = this.readToken();
1480
+ const t = credential ? `t=${encodeURIComponent(credential)}` : "";
1480
1481
  const body = JSON.stringify({ x, y, color });
1481
- const res = await post(this.port(cfg.handPort), `/canvas/fill?${t}`, body, ACTION_TIMEOUT_MS);
1482
- return res.text;
1482
+ const res = await post(this.port(cfg.handPort), `/canvas/fill?${t}`, body, 15e3);
1483
+ return res.body.toString("utf8");
1483
1484
  }
1484
1485
  /** 画板:写文字(支持中文)。 */
1485
1486
  async canvasText(text, x = 24, y = 72, size = 32, color = "#111111") {
1486
1487
  const cfg = this.cfg();
1487
- const t = cfg.token ? `t=${encodeURIComponent(cfg.token)}` : "";
1488
+ const credential = this.readToken();
1489
+ const t = credential ? `t=${encodeURIComponent(credential)}` : "";
1488
1490
  const body = JSON.stringify({ text, x, y, size, color });
1489
- const res = await post(this.port(cfg.handPort), `/canvas/text?${t}`, body, ACTION_TIMEOUT_MS);
1490
- return res.text;
1491
+ const res = await post(this.port(cfg.handPort), `/canvas/text?${t}`, body, 15e3);
1492
+ return res.body.toString("utf8");
1491
1493
  }
1492
1494
  /** 画板:撤销 / 清空 / 保存 / 列表。 */
1493
1495
  async canvasOp(op) {
@@ -1939,12 +1941,12 @@ var HANDS_TOOL_DECLS = [
1939
1941
  {
1940
1942
  name: "canvas_new",
1941
1943
  tags: ["act"],
1942
- description: "\u65B0\u5F00\u4E00\u5F20\u753B\u5E03\uFF08\u9ED8\u8BA4 512\xD7512\uFF0C\u80CC\u666F\u900F\u660E\u6216\u767D\u8272\uFF09\uFF0C\u4F1A\u628A\u5F53\u524D\u8FD9\u5F20\u6E05\u6389\u3002",
1944
+ description: "\u65B0\u5F00\u4E00\u5F20\u753B\u5E03\uFF08\u9ED8\u8BA4 768\xD7768\uFF0C\u80CC\u666F\u900F\u660E\u6216\u767D\u8272\uFF09\uFF0C\u4F1A\u628A\u5F53\u524D\u8FD9\u5F20\u6E05\u6389\u3002",
1943
1945
  parameters: {
1944
1946
  type: "object",
1945
1947
  properties: {
1946
- w: { type: "integer", description: "\u5BBD\uFF0C\u9ED8\u8BA4 512" },
1947
- h: { type: "integer", description: "\u9AD8\uFF0C\u9ED8\u8BA4 512" },
1948
+ w: { type: "integer", description: "\u5BBD\uFF0C\u9ED8\u8BA4 768" },
1949
+ h: { type: "integer", description: "\u9AD8\uFF0C\u9ED8\u8BA4 768" },
1948
1950
  bg: { type: "string", description: "transparent \u6216 white" }
1949
1951
  }
1950
1952
  }
@@ -1958,7 +1960,7 @@ var HANDS_TOOL_DECLS = [
1958
1960
  properties: {
1959
1961
  points: { type: "array", description: "\u5750\u6807 [[x,y],[x,y],\u2026]\uFF0C\u539F\u70B9\u662F\u753B\u5E03\u5DE6\u4E0A\u89D2\uFF1B\u753B\u5706\u7ED9 6\uFF5E10 \u4E2A\u70B9\u5C31\u591F" },
1960
1962
  color: { type: "string", description: "\u989C\u8272\uFF0C#RRGGBB" },
1961
- width: { type: "integer", description: "\u7B14\u753B\u7C97\u7EC6\uFF0C\u9ED8\u8BA4 4" },
1963
+ width: { type: "integer", description: "\u7B14\u753B\u7C97\u7EC6\uFF0C\u9ED8\u8BA4 2\uFF08\u7EC6\u4E00\u70B9\u66F4\u50CF\u624B\u7ED8\uFF09" },
1962
1964
  tool: { type: "string", enum: ["pen", "eraser"], description: "pen=\u753B\u7B14\uFF0Ceraser=\u6A61\u76AE" }
1963
1965
  },
1964
1966
  required: ["points"]
@@ -3423,8 +3425,8 @@ ${text.slice(0, 2200)}`;
3423
3425
  }
3424
3426
  }
3425
3427
  async canvasNew(args) {
3426
- const w = args.w === void 0 ? 512 : Math.max(64, Math.min(2048, Math.round(Number(args.w))));
3427
- const h = args.h === void 0 ? 512 : Math.max(64, Math.min(2048, Math.round(Number(args.h))));
3428
+ const w = args.w === void 0 ? 768 : Math.max(64, Math.min(2048, Math.round(Number(args.w))));
3429
+ const h = args.h === void 0 ? 768 : Math.max(64, Math.min(2048, Math.round(Number(args.h))));
3428
3430
  const bg = typeof args.bg === "string" && args.bg ? args.bg : "transparent";
3429
3431
  return await this.hands.canvasNew(w, h, bg);
3430
3432
  }
@@ -3441,7 +3443,7 @@ ${text.slice(0, 2200)}`;
3441
3443
  }
3442
3444
  if (points.length === 0) return failed("points \u91CC\u6CA1\u6709\u5408\u6CD5\u5750\u6807\u3002");
3443
3445
  const color = typeof args.color === "string" && /^#[0-9a-fA-F]{6}$/.test(args.color) ? args.color : "#111111";
3444
- const width = args.width === void 0 ? 4 : Math.max(1, Math.min(40, Math.round(Number(args.width))));
3446
+ const width = args.width === void 0 ? 2 : Math.max(1, Math.min(40, Math.round(Number(args.width))));
3445
3447
  const tool = args.tool === "eraser" ? "eraser" : "pen";
3446
3448
  return await this.hands.canvasStroke(points, color, width, tool);
3447
3449
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.20.41",
3
+ "version": "0.20.43",
4
4
  "type": "module",
5
5
  "description": "Cortico World: hands for the desktop pet — looks at the phone screen, then taps, swipes, pinches, drags, types and presses keys through whatever actuator the device actually has",
6
6
  "license": "MIT",