@deepraxis/cli 0.3.0-dev.2615392 → 0.3.0-dev.27abe4e

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/COMMANDS.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Generated by `bun run commands`. DO NOT EDIT.
4
4
 
5
- 673 HTTP operations; 675 commands including aliases.
5
+ 676 HTTP operations; 678 commands including aliases.
6
6
 
7
7
  Environment: `PRAXIS_ENV=develop|production` (dev package defaults to `develop`; stable package defaults to `production`). No `--env` option.
8
8
 
@@ -220,16 +220,18 @@ Handwritten commands: `login`, `logout`, `whoami`, `org list`, `org switch <orga
220
220
  | `praxis api browser live get <pageId>` | `browser.live.retrieve` | GET `/browser/v1/live/{sessionId}/{pageId}` | `--live`, `--t` |
221
221
  | `praxis api browser selenium-unsupported get` | `browser.seleniumUnsupported.retrieve` | GET `/browser/v1/selenium-unsupported` | |
222
222
  | `praxis api browser session action create` | `browser.sessions.actions.create` | POST `/browser/v1/sessions/{sessionId}/actions` | `--session` |
223
- | `praxis api browser session create` | `browser.sessions.create` | POST `/browser/v1/sessions` | `--project-id`, `--keep-alive`, `--timeout`, `--region`, `--extension-id`, `--name` |
223
+ | `praxis api browser session create` | `browser.sessions.create` | POST `/browser/v1/sessions` | `--project-id`, `--visibility`, `--keep-alive`, `--timeout`, `--region`, `--extension-id`, `--name` |
224
224
  | `praxis api browser session event list` | `browser.sessions.events.list` | GET `/browser/v1/sessions/{sessionId}/events` | `--session`, `--param-cursor`, `--param-limit`, `--types` |
225
+ | `praxis api browser session frames <sessionId>` | `browser.sessions.frames` | GET `/browser/v1/sessions/{sessionId}/frames` | |
225
226
  | `praxis api browser session get <sessionId>` | `browser.sessions.retrieve` | GET `/browser/v1/sessions/{sessionId}` | `--expand` |
226
227
  | `praxis api browser session get-debug <sessionId>` | `browser.sessions.retrieveDebug` | GET `/browser/v1/sessions/{sessionId}/debug` | |
228
+ | `praxis api browser session get-frame <sessionId>` | `browser.sessions.retrieveFrame` | GET `/browser/v1/sessions/{sessionId}/frame` | |
227
229
  | `praxis api browser session handoff complete` | `browser.sessions.handoff.complete` | POST `/browser/v1/sessions/{sessionId}/handoff/complete` | `--session` |
228
230
  | `praxis api browser session handoff create` | `browser.sessions.handoff.create` | POST `/browser/v1/sessions/{sessionId}/handoff` | `--session`, `--message`, `--timeout-ms` |
229
231
  | `praxis api browser session list` | `browser.sessions.list` | GET `/browser/v1/sessions` | `--status`, `--name`, `--labels`, `--param-cursor`, `--param-limit` |
230
232
  | `praxis api browser session stream <sessionId>` | `browser.sessions.stream` | GET `/browser/v1/sessions/{sessionId}/stream` | |
231
233
  | `praxis api browser session update <sessionId>` | `browser.sessions.update` | POST `/browser/v1/sessions/{sessionId}` | `--status` |
232
- | `praxis api browser session viewer create` | `browser.sessions.viewer.create` | POST `/browser/v1/sessions/{sessionId}/viewer` | `--session`, `--viewer-id` |
234
+ | `praxis api browser session viewer create` | `browser.sessions.viewer.create` | POST `/browser/v1/sessions/{sessionId}/viewer` | `--session`, `--viewer-id`, `--kind` |
233
235
  | `praxis api canvas canvase create` | `canvas.canvases.create` | POST `/canvas/v1/canvases` | `--name` |
234
236
  | `praxis api canvas canvase delete <canvas_id>` | `canvas.canvases.delete` | DELETE `/canvas/v1/canvases/{canvas_id}` | |
235
237
  | `praxis api canvas canvase execute <canvas_id>` | `canvas.canvases.execute` | POST `/canvas/v1/canvases/{canvas_id}:execute` | `--script`, `--edit-id`, `--expected-version` |
@@ -562,11 +564,11 @@ Handwritten commands: `login`, `logout`, `whoami`, `org list`, `org switch <orga
562
564
  | `praxis api search map` | `search.map.create` | POST `/search/v1/map` | `--url`, `--instructions`, `--max-depth`, `--max-breadth`, `--param-limit`, `--select-paths`, `--select-domains`, `--exclude-paths`, `--exclude-domains`, `--allow-external`, `--timeout`, `--include-usage` |
563
565
  | `praxis api studio codex create` | `studio.codexes.create` | POST `/studio/v1/codexes` | `--name`, `--description` |
564
566
  | `praxis api studio codex delete <codex>` | `studio.codexes.delete` | DELETE `/studio/v1/codexes/{codex}` | |
565
- | `praxis api studio codex entry create` | `studio.codexes.entries.create` | POST `/studio/v1/codexes/{codex}/entries` | `--codex`, `--type`, `--name`, `--aliases`, `--case-sensitive`, `--exclude-phrases`, `--description`, `--notes`, `--tracking`, `--images` |
567
+ | `praxis api studio codex entry create` | `studio.codexes.entries.create` | POST `/studio/v1/codexes/{codex}/entries` | `--codex`, `--type`, `--name`, `--group`, `--aliases`, `--case-sensitive`, `--exclude-phrases`, `--description`, `--notes`, `--tracking`, `--images` |
566
568
  | `praxis api studio codex entry delete <entry>` | `studio.codexes.entries.delete` | DELETE `/studio/v1/codexes/{codex}/entries/{entry}` | `--codex` |
567
569
  | `praxis api studio codex entry get <entry>` | `studio.codexes.entries.retrieve` | GET `/studio/v1/codexes/{codex}/entries/{entry}` | `--codex` |
568
570
  | `praxis api studio codex entry list` | `studio.codexes.entries.list` | GET `/studio/v1/codexes/{codex}/entries` | `--codex`, `--page-size`, `--page-token` |
569
- | `praxis api studio codex entry update <entry>` | `studio.codexes.entries.update` | PATCH `/studio/v1/codexes/{codex}/entries/{entry}` | `--codex`, `--update-mask`, `--type`, `--name`, `--aliases`, `--case-sensitive`, `--exclude-phrases`, `--description`, `--notes`, `--tracking`, `--images` |
571
+ | `praxis api studio codex entry update <entry>` | `studio.codexes.entries.update` | PATCH `/studio/v1/codexes/{codex}/entries/{entry}` | `--codex`, `--update-mask`, `--type`, `--name`, `--group`, `--aliases`, `--case-sensitive`, `--exclude-phrases`, `--description`, `--notes`, `--tracking`, `--images` |
570
572
  | `praxis api studio codex get <codex>` | `studio.codexes.retrieve` | GET `/studio/v1/codexes/{codex}` | |
571
573
  | `praxis api studio codex list` | `studio.codexes.list` | GET `/studio/v1/codexes` | `--page-size`, `--page-token` |
572
574
  | `praxis api studio codex update <codex>` | `studio.codexes.update` | PATCH `/studio/v1/codexes/{codex}` | `--update-mask`, `--name`, `--description` |
@@ -662,6 +664,7 @@ Handwritten commands: `login`, `logout`, `whoami`, `org list`, `org switch <orga
662
664
  | `praxis api ticket relation delete <n>` | `ticket.tickets.relations.delete` | DELETE `/ticket/v1/tickets/{number}/relations/{n}` | `--ticket`, `--repository` |
663
665
  | `praxis api ticket relation list` | `ticket.tickets.relations.list` | GET `/ticket/v1/tickets/{number}/relations` | `--ticket`, `--repository`, `--page-size`, `--page-token` |
664
666
  | `praxis api ticket repository list` | `ticket.repositories.list` | GET `/ticket/v1/repositories` | `--page-size`, `--page-token` |
667
+ | `praxis api ticket repository update <id>` | `ticket.repositories.update` | PATCH `/ticket/v1/repositories/{id}` | `--repository` |
665
668
  | `praxis api ticket sub-ticket create` | `ticket.tickets.subTickets.create` | POST `/ticket/v1/tickets/{number}/sub_tickets` | `--ticket`, `--repository`, `--child`, `--replace-parent` |
666
669
  | `praxis api ticket sub-ticket delete <child>` | `ticket.tickets.subTickets.delete` | DELETE `/ticket/v1/tickets/{number}/sub_tickets/{child}` | `--ticket`, `--repository` |
667
670
  | `praxis api ticket sub-ticket list` | `ticket.tickets.subTickets.list` | GET `/ticket/v1/tickets/{number}/sub_tickets` | `--ticket`, `--repository`, `--page-size`, `--page-token` |
package/dist/praxis.js CHANGED
@@ -14312,6 +14312,16 @@ file at the root of that directory.`
14312
14312
  required: false,
14313
14313
  description: "可省略;账户使用 default 项目。"
14314
14314
  },
14315
+ {
14316
+ name: "visibility",
14317
+ type: "string",
14318
+ enum: [
14319
+ "private",
14320
+ "organization"
14321
+ ],
14322
+ required: false,
14323
+ description: "谁能看到这个新会话:默认 private 只有创建者;organization 允许同组织其他成员只读观看画面。"
14324
+ },
14315
14325
  {
14316
14326
  name: "keepAlive",
14317
14327
  type: "boolean",
@@ -14503,6 +14513,42 @@ file at the root of that directory.`
14503
14513
  }
14504
14514
  ]
14505
14515
  },
14516
+ {
14517
+ resource: "browser.sessions",
14518
+ method: "retrieveFrame",
14519
+ summary: "读取会话只读画面帧",
14520
+ description: "读取会话的一张只读画面帧(JPEG 字节)。创建者可读,同组织其他成员只在该会话声明为组织可见时可读;其余情况一律返回 404 SESSION_NOT_FOUND,不提示会话是否存在。响应体没有任何可控制浏览器的凭据,且不接受任何动作参数。",
14521
+ http: "GET",
14522
+ path: "/browser/v1/sessions/{sessionId}/frame",
14523
+ streaming: "no",
14524
+ pagination: false,
14525
+ pathParams: [
14526
+ {
14527
+ name: "sessionId",
14528
+ sdkName: "sessionId",
14529
+ description: "浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。"
14530
+ }
14531
+ ],
14532
+ query: []
14533
+ },
14534
+ {
14535
+ resource: "browser.sessions",
14536
+ method: "frames",
14537
+ summary: "订阅会话只读画面",
14538
+ description: "SSE:只推送只读画面帧,event 为 frame 或 end,data 为帧的 JSON 或 null;帧 data 是 JPEG 的 base64 编码,ts 是浏览器产生该帧的时刻(epoch 毫秒),约每秒最多 5 帧。评论 ping 每 15 秒一次,end 后关闭。这条通道与 /sessions/{sessionId}/stream 相互独立:它的消息只含画面,绝不含 wsUrl、signingKey、connectUrl、debuggerUrl、debuggerFullscreenUrl。创建者可订阅,同组织其他成员只在该会话声明为组织可见时可订阅;其余情况一律返回 404 SESSION_NOT_FOUND。",
14539
+ http: "GET",
14540
+ path: "/browser/v1/sessions/{sessionId}/frames",
14541
+ streaming: "always",
14542
+ pagination: false,
14543
+ pathParams: [
14544
+ {
14545
+ name: "sessionId",
14546
+ sdkName: "sessionId",
14547
+ description: "浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。"
14548
+ }
14549
+ ],
14550
+ query: []
14551
+ },
14506
14552
  {
14507
14553
  resource: "browser.sessions.handoff",
14508
14554
  method: "create",
@@ -14599,6 +14645,16 @@ file at the root of that directory.`
14599
14645
  type: "string",
14600
14646
  required: true,
14601
14647
  description: "当前观看者的稳定标识;同一观看者重复心跳应使用相同值,长度为 1–128 个 UTF-16 代码单元。"
14648
+ },
14649
+ {
14650
+ name: "kind",
14651
+ type: "string",
14652
+ enum: [
14653
+ "control",
14654
+ "readonly"
14655
+ ],
14656
+ required: false,
14657
+ description: "观看者类型:control 是需要控制浏览器的客户端,readonly 是只读观看者。只读观看者发送 control 也会按 readonly 记录。"
14602
14658
  }
14603
14659
  ]
14604
14660
  }
@@ -32273,6 +32329,31 @@ for more details.`
32273
32329
  }
32274
32330
  ]
32275
32331
  },
32332
+ {
32333
+ resource: "ticket.repositories",
32334
+ method: "update",
32335
+ summary: "Update repositories",
32336
+ description: "Update repositories within the authenticated organization. Obtain resource identifiers from the corresponding list or create response. Writes complete synchronously; read the returned resource to observe the result. Service authorization applies to the verified human subject.",
32337
+ http: "PATCH",
32338
+ path: "/ticket/v1/repositories/{id}",
32339
+ streaming: "no",
32340
+ pagination: false,
32341
+ pathParams: [
32342
+ {
32343
+ name: "id",
32344
+ sdkName: "id",
32345
+ description: "Identifier returned by the matching create or list operation; number paths take repository-local numbers."
32346
+ }
32347
+ ],
32348
+ query: [
32349
+ {
32350
+ name: "repository",
32351
+ type: "string",
32352
+ required: false,
32353
+ description: "Repository id from GET /ticket/v1/repositories; omit for the default tickets container."
32354
+ }
32355
+ ]
32356
+ },
32276
32357
  {
32277
32358
  resource: "ticket.tickets",
32278
32359
  method: "list",
@@ -35692,6 +35773,15 @@ var browserViewerHeartbeat = (options) => (options.client ?? client).post({
35692
35773
  ...options.headers
35693
35774
  }
35694
35775
  });
35776
+ var browserGetSessionFrame = (options) => (options.client ?? client).get({
35777
+ security: [{
35778
+ key: "BrowserBearer",
35779
+ scheme: "bearer",
35780
+ type: "http"
35781
+ }],
35782
+ url: "/browser/v1/sessions/{sessionId}/frame",
35783
+ ...options
35784
+ });
35695
35785
  var browserListContexts = (options) => (options?.client ?? client).get({
35696
35786
  security: [{
35697
35787
  key: "BrowserBearer",
@@ -35780,6 +35870,15 @@ var browserStreamSession = (options) => (options.client ?? client).sse.get({
35780
35870
  url: "/browser/v1/sessions/{sessionId}/stream",
35781
35871
  ...options
35782
35872
  });
35873
+ var browserStreamSessionFrames = (options) => (options.client ?? client).sse.get({
35874
+ security: [{
35875
+ key: "BrowserBearer",
35876
+ scheme: "bearer",
35877
+ type: "http"
35878
+ }],
35879
+ url: "/browser/v1/sessions/{sessionId}/frames",
35880
+ ...options
35881
+ });
35783
35882
  var browserSeleniumUnsupported = (options) => (options?.client ?? client).get({
35784
35883
  security: [{
35785
35884
  key: "BrowserBearer",
@@ -44199,6 +44298,19 @@ var ticketGetRepositories = (options) => (options?.client ?? client).get({
44199
44298
  url: "/ticket/v1/repositories",
44200
44299
  ...options
44201
44300
  });
44301
+ var ticketPatchRepositoriesId = (options) => (options.client ?? client).patch({
44302
+ security: [{
44303
+ key: "BearerAuth",
44304
+ scheme: "bearer",
44305
+ type: "http"
44306
+ }, {
44307
+ key: "ApiKeyAuth",
44308
+ name: "X-API-Key",
44309
+ type: "apiKey"
44310
+ }],
44311
+ url: "/ticket/v1/repositories/{id}",
44312
+ ...options
44313
+ });
44202
44314
 
44203
44315
  // ../../packages/sdk/typescript/src/core/pagination.ts
44204
44316
  class Page {
@@ -44646,6 +44758,7 @@ function createBrowser(transport) {
44646
44758
  events: {
44647
44759
  list: bind(transport, browserListEvents)
44648
44760
  },
44761
+ frames: bindStream(transport, browserStreamSessionFrames),
44649
44762
  handoff: {
44650
44763
  complete: bind(transport, browserCompleteHandoff),
44651
44764
  create: bind(transport, browserRequestHandoff)
@@ -44653,6 +44766,7 @@ function createBrowser(transport) {
44653
44766
  list: bind(transport, browserListSessions),
44654
44767
  retrieve: bind(transport, browserGetSession),
44655
44768
  retrieveDebug: bind(transport, browserGetDebug),
44769
+ retrieveFrame: bind(transport, browserGetSessionFrame),
44656
44770
  stream: bindStream(transport, browserStreamSession),
44657
44771
  update: bind(transport, browserCloseSession),
44658
44772
  viewer: {
@@ -45492,7 +45606,8 @@ function createTicket(transport) {
45492
45606
  update: bind(transport, ticketPatchMilestonesNumber)
45493
45607
  },
45494
45608
  repositories: {
45495
- list: bind(transport, ticketGetRepositories)
45609
+ list: bind(transport, ticketGetRepositories),
45610
+ update: bind(transport, ticketPatchRepositoriesId)
45496
45611
  },
45497
45612
  tickets: {
45498
45613
  comments: {
@@ -49781,7 +49896,7 @@ function retop(store, id, top, rev) {
49781
49896
  // ../../packages/canvas/document/src/connector.ts
49782
49897
  var MAGNETS = ["auto", "center", "top", "right", "bottom", "left"];
49783
49898
  var ARROWS = ["end", "start", "both", "none"];
49784
- var ROUTES = ["straight"];
49899
+ var ROUTES = ["straight", "elbow"];
49785
49900
  var ARROW_LENGTH_FACTOR = 6;
49786
49901
  var ARROW_HALF_ANGLE_DEG = 25;
49787
49902
  var EPSILON = 0.000000001;
@@ -49869,6 +49984,30 @@ function normalize(p) {
49869
49984
  const l = Math.hypot(p.x, p.y);
49870
49985
  return { x: p.x / l, y: p.y / l };
49871
49986
  }
49987
+ function rectsOverlap(a, b) {
49988
+ return a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height;
49989
+ }
49990
+ function segmentCrossesBox(a, b, box) {
49991
+ const shrink = 0.000001;
49992
+ const dx = b.x - a.x;
49993
+ const dy = b.y - a.y;
49994
+ let t0 = 0;
49995
+ let t1 = 1;
49996
+ const slab = (start, delta, min, max) => {
49997
+ if (Math.abs(delta) < 0.000000000001)
49998
+ return start > min && start < max;
49999
+ const ta = (min - start) / delta;
50000
+ const tb = (max - start) / delta;
50001
+ t0 = Math.max(t0, Math.min(ta, tb));
50002
+ t1 = Math.min(t1, Math.max(ta, tb));
50003
+ return t0 <= t1;
50004
+ };
50005
+ if (!slab(a.x, dx, box.x + shrink, box.x + box.width - shrink))
50006
+ return false;
50007
+ if (!slab(a.y, dy, box.y + shrink, box.y + box.height - shrink))
50008
+ return false;
50009
+ return t1 > t0;
50010
+ }
49872
50011
  function dashRanges(length, dash) {
49873
50012
  const pattern = (dash ?? []).filter((d) => typeof d === "number" && Number.isFinite(d) && d > 0);
49874
50013
  if (!pattern.length)
@@ -49890,40 +50029,105 @@ function n(value) {
49890
50029
  const rounded = Math.round(value * 100) / 100;
49891
50030
  return String(Object.is(rounded, -0) ? 0 : rounded);
49892
50031
  }
50032
+ var isHorizontal = (side) => side === "left" || side === "right";
50033
+ function elbowPath(from, to, fromMagnet, toMagnet) {
50034
+ if (fromMagnet === "center" || toMagnet === "center")
50035
+ throw new OpRejectedError({
50036
+ code: "INVALID_VALUE",
50037
+ property: fromMagnet === "center" ? "fromMagnet" : "toMagnet",
50038
+ reason: "elbow routing needs an edge, not the centre"
50039
+ });
50040
+ const dx = centerOf(to.box).x - centerOf(from.box).x;
50041
+ const dy = centerOf(to.box).y - centerOf(from.box).y;
50042
+ const across = Math.abs(dx) > Math.abs(dy);
50043
+ const fromSide = fromMagnet === "auto" ? across ? dx > 0 ? "right" : "left" : dy > 0 ? "bottom" : "top" : fromMagnet;
50044
+ const toSide = toMagnet === "auto" ? across ? dx > 0 ? "left" : "right" : dy > 0 ? "top" : "bottom" : toMagnet;
50045
+ const p1 = magnetPoint(from.box, fromSide);
50046
+ const p2 = magnetPoint(to.box, toSide);
50047
+ const out = [p1];
50048
+ if (isHorizontal(fromSide) === isHorizontal(toSide)) {
50049
+ if (isHorizontal(fromSide)) {
50050
+ const midX = (p1.x + p2.x) / 2;
50051
+ out.push({ x: midX, y: p1.y }, { x: midX, y: p2.y });
50052
+ } else {
50053
+ const midY = (p1.y + p2.y) / 2;
50054
+ out.push({ x: p1.x, y: midY }, { x: p2.x, y: midY });
50055
+ }
50056
+ } else {
50057
+ out.push(isHorizontal(fromSide) ? { x: p2.x, y: p1.y } : { x: p1.x, y: p2.y });
50058
+ }
50059
+ out.push(p2);
50060
+ const kept = [];
50061
+ for (const p of out) {
50062
+ const last = kept[kept.length - 1];
50063
+ if (last && last.x === p.x && last.y === p.y)
50064
+ continue;
50065
+ if (last && kept.length >= 2) {
50066
+ const before = kept[kept.length - 2];
50067
+ if (before.x === last.x && last.x === p.x || before.y === last.y && last.y === p.y)
50068
+ kept.pop();
50069
+ }
50070
+ kept.push(p);
50071
+ }
50072
+ return kept;
50073
+ }
50074
+ function cumulative(points) {
50075
+ const cum = [0];
50076
+ for (let i = 1;i < points.length; i++)
50077
+ cum.push(cum[i - 1] + Math.hypot(points[i].x - points[i - 1].x, points[i].y - points[i - 1].y));
50078
+ return cum;
50079
+ }
50080
+ function pointAt(points, cum, s) {
50081
+ const total = cum[cum.length - 1];
50082
+ const at = Math.max(0, Math.min(s, total));
50083
+ let i = 0;
50084
+ while (i < points.length - 2 && cum[i + 1] < at)
50085
+ i++;
50086
+ const span = cum[i + 1] - cum[i];
50087
+ const f = span < EPSILON ? 0 : (at - cum[i]) / span;
50088
+ const a = points[i];
50089
+ const b = points[i + 1];
50090
+ return { x: a.x + (b.x - a.x) * f, y: a.y + (b.y - a.y) * f };
50091
+ }
49893
50092
  function connectorGeometry(from, to, opts = {}) {
49894
50093
  const arrow = opts.arrow ?? "end";
49895
50094
  const strokeWidth = opts.strokeWidth ?? 1.5;
49896
50095
  const labelPos = opts.labelPos ?? 0.5;
49897
50096
  const fromMagnet = opts.fromMagnet ?? "auto";
49898
50097
  const toMagnet = opts.toMagnet ?? "auto";
49899
- const fromCenter = centerOf(from.box);
49900
- const toCenter = centerOf(to.box);
49901
- const p1 = endPoint(from, fromMagnet, toCenter);
49902
- const p2 = endPoint(to, toMagnet, fromCenter);
49903
- const length = Math.hypot(p2.x - p1.x, p2.y - p1.y);
50098
+ if (rectsOverlap(from.box, to.box))
50099
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "from", reason: "nodes overlap" });
50100
+ const points = (opts.route ?? "straight") === "elbow" ? elbowPath(from, to, fromMagnet, toMagnet) : [endPoint(from, fromMagnet, centerOf(to.box)), endPoint(to, toMagnet, centerOf(from.box))];
50101
+ const cum = cumulative(points);
50102
+ const length = cum[cum.length - 1];
50103
+ const p1 = points[0];
50104
+ const p2 = points[points.length - 1];
49904
50105
  if (length < EPSILON || inside(p1, to.box) || inside(p2, from.box))
49905
50106
  throw new OpRejectedError({ code: "INVALID_VALUE", property: "from", reason: "nodes overlap" });
49906
- const dir = normalize({ x: p2.x - p1.x, y: p2.y - p1.y });
49907
- const back = { x: -dir.x, y: -dir.y };
50107
+ const dir1 = normalize({ x: points[1].x - p1.x, y: points[1].y - p1.y });
50108
+ const dir2 = normalize({ x: p2.x - points[points.length - 2].x, y: p2.y - points[points.length - 2].y });
50109
+ const back = { x: -dir2.x, y: -dir2.y };
49908
50110
  const arrowHeads = [];
49909
50111
  if (arrow === "end" || arrow === "both")
49910
50112
  arrowHeads.push(arrowHead(p2, back, strokeWidth));
49911
50113
  if (arrow === "start" || arrow === "both")
49912
- arrowHeads.push(arrowHead(p1, dir, strokeWidth));
49913
- const xs = [p1.x, p2.x];
49914
- const ys = [p1.y, p2.y];
50114
+ arrowHeads.push(arrowHead(p1, dir1, strokeWidth));
50115
+ const xs = points.map((p) => p.x);
50116
+ const ys = points.map((p) => p.y);
49915
50117
  for (const head of arrowHeads) {
49916
50118
  xs.push(head.tip.x, head.left.x, head.right.x);
49917
50119
  ys.push(head.tip.y, head.left.y, head.right.y);
49918
50120
  }
49919
50121
  const bbox = { x: Math.min(...xs), y: Math.min(...ys), width: Math.max(...xs) - Math.min(...xs), height: Math.max(...ys) - Math.min(...ys) };
49920
50122
  const local = (p) => ({ x: p.x - bbox.x, y: p.y - bbox.y });
49921
- const at = (t) => ({ x: p1.x + (p2.x - p1.x) * t, y: p1.y + (p2.y - p1.y) * t });
49922
50123
  const parts = [];
49923
50124
  for (const [start, end] of dashRanges(length, opts.dash)) {
49924
- const a = local(at(start / length));
49925
- const b = local(at(end / length));
49926
- parts.push(`M${n(a.x)} ${n(a.y)}L${n(b.x)} ${n(b.y)}`);
50125
+ const run = [pointAt(points, cum, start)];
50126
+ for (let i = 1;i < points.length - 1; i++)
50127
+ if (cum[i] > start + EPSILON && cum[i] < end - EPSILON)
50128
+ run.push(points[i]);
50129
+ run.push(pointAt(points, cum, end));
50130
+ parts.push(run.map((p, i) => `${i ? "L" : "M"}${n(local(p).x)} ${n(local(p).y)}`).join(""));
49927
50131
  }
49928
50132
  for (const head of arrowHeads) {
49929
50133
  const t = local(head.tip);
@@ -49931,7 +50135,7 @@ function connectorGeometry(from, to, opts = {}) {
49931
50135
  const r = local(head.right);
49932
50136
  parts.push(`M${n(t.x)} ${n(t.y)}L${n(l.x)} ${n(l.y)}L${n(r.x)} ${n(r.y)}Z`);
49933
50137
  }
49934
- return { points: [p1, p2], arrowHeads, bbox, labelCenter: at(labelPos), geometry: parts.join("") };
50138
+ return { points: [p1, p2], polyline: points, arrowHeads, bbox, labelCenter: pointAt(points, cum, labelPos * length), geometry: parts.join("") };
49935
50139
  }
49936
50140
  // ../../packages/canvas/document/src/expand.ts
49937
50141
  function defaultTheme(themes) {
@@ -50318,10 +50522,368 @@ function planRefs(plan) {
50318
50522
  return { refs, ids };
50319
50523
  }
50320
50524
 
50525
+ // ../../packages/canvas/document/src/kit-builders.ts
50526
+ var PRAXIS_UI_LITERALS = {
50527
+ "v3-surface-2": "#F1F3F2",
50528
+ "v3-border": "#E3E7E4",
50529
+ "v3-border-strong": "#CDD3CF",
50530
+ "v3-fg": "#0D1310",
50531
+ "v3-fg-2": "#4A5550",
50532
+ "v3-fg-3": "#6E7872",
50533
+ "v3-green-50": "#EEFBF3",
50534
+ "v3-green-700": "#167A43",
50535
+ "v3-code-bg": "#0F1512",
50536
+ "v3-code-fg": "#D6E2DB",
50537
+ "v3-danger": "#D92D20",
50538
+ "v3-danger-soft": "#FEF0EE",
50539
+ "v3-warning": "#C76A00",
50540
+ "v3-warning-soft": "#FFF6E5",
50541
+ "v3-info": "#2563EB",
50542
+ "v3-info-soft": "#EEF4FF",
50543
+ "v3-font": "Geist",
50544
+ "v3-mono": "Geist Mono",
50545
+ "r-md": 8
50546
+ };
50547
+ function token(ctx, name) {
50548
+ return ctx.variables.has(name) ? `$${name}` : PRAXIS_UI_LITERALS[name];
50549
+ }
50550
+ var KIT_LIMITS = {
50551
+ tableRows: 200,
50552
+ codeLines: 200,
50553
+ keyWidth: 240,
50554
+ minColumn: 24
50555
+ };
50556
+ var COLUMN_GAP = 12;
50557
+ var ROW_PADDING = 10;
50558
+ var BODY_SIZE = 13;
50559
+ var HEADER_SIZE = 12;
50560
+ function invalid(property, reason) {
50561
+ throw new OpRejectedError({ code: "INVALID_VALUE", property, reason });
50562
+ }
50563
+ function optionKeys(value, allowed, name) {
50564
+ if (value === undefined || value === null)
50565
+ return {};
50566
+ if (typeof value !== "object" || Array.isArray(value))
50567
+ return invalid(name, "expected an options object");
50568
+ for (const key of Object.keys(value))
50569
+ if (!allowed.includes(key))
50570
+ return invalid(key, `${name} does not take ${key}`);
50571
+ return value;
50572
+ }
50573
+ function requiredString(value, property) {
50574
+ if (typeof value !== "string" || value === "")
50575
+ return invalid(property, "expected a non-empty string");
50576
+ return value;
50577
+ }
50578
+ function optionalString(value, property) {
50579
+ if (value === undefined || value === null)
50580
+ return;
50581
+ return requiredString(value, property);
50582
+ }
50583
+ function containerWidth(value, property) {
50584
+ if (value === undefined || value === null || value === "fill_container")
50585
+ return "fill_container";
50586
+ if (typeof value === "number" && Number.isFinite(value) && value > 0)
50587
+ return value;
50588
+ return invalid(property, 'expected a positive number or "fill_container"');
50589
+ }
50590
+ var TABLE_KEYS = ["columns", "rows", "zebra", "width"];
50591
+ var COLUMN_KEYS = ["key", "title", "width", "align"];
50592
+ var requestOf = (width) => typeof width === "number" ? width : KIT_LIMITS.minColumn;
50593
+ function planColumns(columns, total, gap = COLUMN_GAP) {
50594
+ const fills = columns.filter((c) => typeof c.width !== "number").length;
50595
+ if (total === null)
50596
+ return columns.map((c) => typeof c.width === "number" ? c.width : "fill_container");
50597
+ const available = Math.max(0, total - gap * Math.max(0, columns.length - 1));
50598
+ const pinned = columns.reduce((sum, c) => sum + (typeof c.width === "number" ? c.width : 0), 0);
50599
+ const leftover = available - pinned;
50600
+ if (leftover > 0) {
50601
+ if (!fills)
50602
+ return columns.map((c) => c.width);
50603
+ const share = round2(leftover / fills);
50604
+ return columns.map((c) => typeof c.width === "number" ? c.width : share);
50605
+ }
50606
+ const requested = columns.reduce((sum, c) => sum + requestOf(c.width), 0);
50607
+ const scale = requested > 0 ? available / requested : 1;
50608
+ return columns.map((c) => Math.max(1, round2(requestOf(c.width) * scale)));
50609
+ }
50610
+ var round2 = (n2) => Math.round(n2 * 100) / 100;
50611
+ function cellRow(name, cells) {
50612
+ return { type: "frame", name, layout: "horizontal", gap: COLUMN_GAP, padding: [ROW_PADDING, 0], width: "fill_container", children: cells };
50613
+ }
50614
+ function planTable(options, ctx) {
50615
+ const o = optionKeys(options, TABLE_KEYS, "Kit.Table");
50616
+ if (!Array.isArray(o.columns) || o.columns.length === 0)
50617
+ invalid("columns", "expected a non-empty array of { key, title }");
50618
+ const rows = o.rows;
50619
+ if (!Array.isArray(rows))
50620
+ invalid("rows", "expected an array of row objects");
50621
+ if (rows.length > KIT_LIMITS.tableRows)
50622
+ invalid("rows", `${rows.length} rows; a table renders at most ${KIT_LIMITS.tableRows} — split it, or build the frame by hand`);
50623
+ const columns = o.columns.map((raw, i) => {
50624
+ const c = optionKeys(raw, COLUMN_KEYS, `columns[${i}]`);
50625
+ const width2 = c.width;
50626
+ if (width2 !== undefined && width2 !== null && width2 !== "fill" && !(typeof width2 === "number" && Number.isFinite(width2) && width2 > 0))
50627
+ invalid(`columns[${i}].width`, 'expected a positive number or "fill"');
50628
+ const align = c.align;
50629
+ if (align !== undefined && align !== null && align !== "left" && align !== "right")
50630
+ invalid(`columns[${i}].align`, 'expected "left" or "right"');
50631
+ return { key: requiredString(c.key, `columns[${i}].key`), title: requiredString(c.title, `columns[${i}].title`), width: width2, align };
50632
+ });
50633
+ const width = containerWidth(o.width, "width");
50634
+ const widths = planColumns(columns, typeof width === "number" ? width : null, COLUMN_GAP);
50635
+ const font = token(ctx, "v3-font");
50636
+ const headerCell = (title, w, align) => ({
50637
+ type: "text",
50638
+ name: title,
50639
+ content: title,
50640
+ width: w,
50641
+ textGrowth: "fixed-width",
50642
+ fontFamily: font,
50643
+ fontSize: HEADER_SIZE,
50644
+ fontWeight: 600,
50645
+ fill: token(ctx, "v3-fg-2"),
50646
+ ...align === "right" ? { textAlign: "right" } : {}
50647
+ });
50648
+ const dataCell = (title, content, w, align) => ({
50649
+ type: "text",
50650
+ name: title,
50651
+ content,
50652
+ width: w,
50653
+ textGrowth: "fixed-width",
50654
+ fontFamily: font,
50655
+ fontSize: BODY_SIZE,
50656
+ fill: token(ctx, "v3-fg"),
50657
+ ...align === "right" ? { textAlign: "right" } : {}
50658
+ });
50659
+ const children = [
50660
+ {
50661
+ type: "frame",
50662
+ name: "Header",
50663
+ layout: "vertical",
50664
+ gap: 0,
50665
+ width: "fill_container",
50666
+ stroke: token(ctx, "v3-border-strong"),
50667
+ strokeWidth: { bottom: 1 },
50668
+ strokeAlignment: "inner",
50669
+ children: [cellRow("HeaderRow", columns.map((c, i) => headerCell(c.title, widths[i], c.align)))]
50670
+ }
50671
+ ];
50672
+ rows.forEach((row, i) => {
50673
+ const record = row && typeof row === "object" && !Array.isArray(row) ? row : {};
50674
+ children.push({
50675
+ type: "frame",
50676
+ name: "Row",
50677
+ layout: "vertical",
50678
+ gap: 0,
50679
+ width: "fill_container",
50680
+ stroke: token(ctx, "v3-border"),
50681
+ strokeWidth: { bottom: 1 },
50682
+ strokeAlignment: "inner",
50683
+ ...o.zebra === true && i % 2 === 1 ? { fill: token(ctx, "v3-surface-2") } : {},
50684
+ children: [cellRow("RowCells", columns.map((c, j) => dataCell(c.key, textOf(record[c.key]), widths[j], c.align)))]
50685
+ });
50686
+ });
50687
+ return { type: "frame", name: "Table", layout: "vertical", gap: 0, width, children };
50688
+ }
50689
+ function textOf(value) {
50690
+ if (value === undefined || value === null)
50691
+ return "";
50692
+ return typeof value === "string" ? value : String(value);
50693
+ }
50694
+ function requiredText(value, property) {
50695
+ if (typeof value !== "string" && typeof value !== "number")
50696
+ return invalid(property, "expected a string or number");
50697
+ return String(value);
50698
+ }
50699
+ var CALLOUT_KEYS = ["tone", "title", "body"];
50700
+ var CALLOUT_TONES = {
50701
+ info: { soft: "v3-info-soft", ink: "v3-info" },
50702
+ success: { soft: "v3-green-50", ink: "v3-green-700" },
50703
+ warning: { soft: "v3-warning-soft", ink: "v3-warning" },
50704
+ danger: { soft: "v3-danger-soft", ink: "v3-danger" }
50705
+ };
50706
+ function planCallout(options, ctx) {
50707
+ const o = optionKeys(options, CALLOUT_KEYS, "Kit.Callout");
50708
+ const tone = o.tone;
50709
+ if (typeof tone !== "string" || !Object.hasOwn(CALLOUT_TONES, tone))
50710
+ invalid("tone", `expected one of ${Object.keys(CALLOUT_TONES).join(", ")}`);
50711
+ const body = requiredString(o.body, "body");
50712
+ const title = optionalString(o.title, "title");
50713
+ const pair = CALLOUT_TONES[tone];
50714
+ const font = token(ctx, "v3-font");
50715
+ const bodyChildren = [];
50716
+ if (title !== undefined)
50717
+ bodyChildren.push({ type: "text", name: "Title", content: title, fontFamily: font, fontSize: BODY_SIZE, fontWeight: 600, fill: token(ctx, pair.ink) });
50718
+ bodyChildren.push({
50719
+ type: "text",
50720
+ name: "Body",
50721
+ content: body,
50722
+ fontFamily: font,
50723
+ fontSize: BODY_SIZE,
50724
+ lineHeight: 1.5,
50725
+ width: "fill_container",
50726
+ textGrowth: "fixed-width",
50727
+ fill: token(ctx, "v3-fg")
50728
+ });
50729
+ return {
50730
+ type: "frame",
50731
+ name: "Callout",
50732
+ layout: "horizontal",
50733
+ gap: 0,
50734
+ width: "fill_container",
50735
+ fill: token(ctx, pair.soft),
50736
+ cornerRadius: token(ctx, "r-md"),
50737
+ clip: true,
50738
+ children: [
50739
+ { type: "rectangle", name: "Bar", width: 3, height: "fill_container", fill: token(ctx, pair.ink) },
50740
+ { type: "frame", name: "Content", layout: "vertical", gap: 6, padding: [12, 14], width: "fill_container", children: bodyChildren }
50741
+ ]
50742
+ };
50743
+ }
50744
+ var CODE_KEYS = ["lang", "text"];
50745
+ function planCode(options, ctx) {
50746
+ const o = optionKeys(options, CODE_KEYS, "Kit.Code");
50747
+ const lang = optionalString(o.lang, "lang");
50748
+ const text = requiredString(o.text, "text");
50749
+ const lines = text.split(`
50750
+ `);
50751
+ const shown = lines.length > KIT_LIMITS.codeLines ? [...lines.slice(0, KIT_LIMITS.codeLines), `… ${lines.length - KIT_LIMITS.codeLines} more lines`] : lines;
50752
+ const children = [];
50753
+ if (lang !== undefined)
50754
+ children.push({
50755
+ type: "text",
50756
+ name: "Lang",
50757
+ content: lang,
50758
+ width: "fill_container",
50759
+ textGrowth: "fixed-width",
50760
+ textAlign: "right",
50761
+ fontFamily: token(ctx, "v3-mono"),
50762
+ fontSize: 11,
50763
+ fill: token(ctx, "v3-fg-3")
50764
+ });
50765
+ children.push({
50766
+ type: "text",
50767
+ name: "Lines",
50768
+ content: shown.join(`
50769
+ `),
50770
+ fontFamily: token(ctx, "v3-mono"),
50771
+ fontSize: 12,
50772
+ lineHeight: 1.5,
50773
+ width: "fill_container",
50774
+ textGrowth: "fixed-width",
50775
+ fill: token(ctx, "v3-code-fg")
50776
+ });
50777
+ return {
50778
+ type: "frame",
50779
+ name: "Code",
50780
+ layout: "vertical",
50781
+ gap: 6,
50782
+ width: "fill_container",
50783
+ fill: token(ctx, "v3-code-bg"),
50784
+ cornerRadius: token(ctx, "r-md"),
50785
+ padding: 12,
50786
+ clip: true,
50787
+ children
50788
+ };
50789
+ }
50790
+ function indexed(index) {
50791
+ return /^\d+$/.test(index) ? index.padStart(2, "0") : index;
50792
+ }
50793
+ var SECTION_KEYS = ["index", "title", "subtitle"];
50794
+ function planSection(options, ctx) {
50795
+ const o = optionKeys(options, SECTION_KEYS, "Kit.Section");
50796
+ const title = requiredString(o.title, "title");
50797
+ const subtitle = optionalString(o.subtitle, "subtitle");
50798
+ const index = o.index === undefined || o.index === null ? undefined : textOf(o.index);
50799
+ if (index !== undefined && index === "")
50800
+ invalid("index", "expected a non-empty string or number");
50801
+ const font = token(ctx, "v3-font");
50802
+ const heading = {
50803
+ type: "frame",
50804
+ name: "Heading",
50805
+ layout: "horizontal",
50806
+ gap: 8,
50807
+ alignItems: "center",
50808
+ width: "fill_container",
50809
+ children: [
50810
+ ...index === undefined ? [] : [{ type: "text", name: "Index", content: indexed(index), fontFamily: font, fontSize: 14, fill: token(ctx, "v3-fg-3") }],
50811
+ { type: "text", name: "Title", content: title, fontFamily: font, fontSize: 20, fontWeight: 600, fill: token(ctx, "v3-fg"), width: "fill_container", textGrowth: "fixed-width" }
50812
+ ]
50813
+ };
50814
+ const children = [heading];
50815
+ if (subtitle !== undefined)
50816
+ children.push({ type: "text", name: "Subtitle", content: subtitle, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg-2"), width: "fill_container", textGrowth: "fixed-width" });
50817
+ return { type: "frame", name: "Section", layout: "vertical", gap: 4, padding: [0, 0, 16, 0], width: "fill_container", children };
50818
+ }
50819
+ function planKeyValue(rows, ctx) {
50820
+ if (!Array.isArray(rows) || rows.length === 0)
50821
+ invalid("rows", "expected a non-empty array of { key, value }");
50822
+ const font = token(ctx, "v3-font");
50823
+ const parsed = rows.map((raw, i) => {
50824
+ const r = optionKeys(raw, ["key", "value"], `rows[${i}]`);
50825
+ return { key: requiredString(r.key, `rows[${i}].key`), value: requiredText(r.value, `rows[${i}].value`) };
50826
+ });
50827
+ const measured = Math.max(...parsed.map((r) => ctx.measure({ content: r.key, fontFamily: String(font), fontSize: BODY_SIZE }).width));
50828
+ const keyWidth = Math.min(KIT_LIMITS.keyWidth, Math.max(1, Math.ceil(measured)));
50829
+ return {
50830
+ type: "frame",
50831
+ name: "KeyValue",
50832
+ layout: "vertical",
50833
+ gap: 0,
50834
+ width: "fill_container",
50835
+ children: parsed.map((r) => ({
50836
+ type: "frame",
50837
+ name: "KeyValueRow",
50838
+ layout: "horizontal",
50839
+ gap: 12,
50840
+ padding: [6, 0],
50841
+ width: "fill_container",
50842
+ children: [
50843
+ { type: "text", name: "Key", content: r.key, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg-3"), width: keyWidth, textGrowth: "fixed-width" },
50844
+ { type: "text", name: "Value", content: r.value, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg"), width: "fill_container", textGrowth: "fixed-width" }
50845
+ ]
50846
+ }))
50847
+ };
50848
+ }
50849
+ var KIT_BUILDERS = {
50850
+ table: planTable,
50851
+ callout: planCallout,
50852
+ code: planCode,
50853
+ section: planSection,
50854
+ "key-value": planKeyValue
50855
+ };
50856
+ function planKitNode(kind, options, ctx) {
50857
+ const build = typeof kind === "string" && Object.hasOwn(KIT_BUILDERS, kind) ? KIT_BUILDERS[kind] : undefined;
50858
+ if (!build)
50859
+ return invalid("kind", `unknown builder ${JSON.stringify(kind)}; expected one of ${Object.keys(KIT_BUILDERS).join(", ")}`);
50860
+ return build(options, ctx);
50861
+ }
50862
+
50321
50863
  // ../../packages/canvas/document/src/execute-api.ts
50864
+ var MOVING_KEYS = ["x", "y", "width", "height", "layout", "layoutPosition", "padding", "gap", "justifyContent", "alignItems", "cornerRadius", "rotation"];
50322
50865
  var CONNECT_KEYS = new Set(["route", "fromMagnet", "toMagnet", "arrow", "label", "labelPos", "stroke", "strokeWidth", "dash", "behind", "parent", "name"]);
50866
+ function connectorMetaOf(props) {
50867
+ const meta = props?.metadata?.connector;
50868
+ if (!meta || typeof meta !== "object")
50869
+ return null;
50870
+ const m = meta;
50871
+ if (typeof m.from !== "string" || typeof m.to !== "string")
50872
+ return null;
50873
+ return {
50874
+ from: m.from,
50875
+ to: m.to,
50876
+ fromMagnet: m.fromMagnet ?? "auto",
50877
+ toMagnet: m.toMagnet ?? "auto",
50878
+ route: m.route ?? "straight",
50879
+ arrow: m.arrow ?? "end",
50880
+ labelPos: typeof m.labelPos === "number" ? m.labelPos : 0.5,
50881
+ ...Array.isArray(m.dash) ? { dash: m.dash } : {},
50882
+ ...typeof m.labelId === "string" ? { labelId: m.labelId } : {}
50883
+ };
50884
+ }
50323
50885
  var MEASURE_KEYS = new Set(["fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "width"]);
50324
- function invalid(property, reason) {
50886
+ function invalid2(property, reason) {
50325
50887
  throw new OpRejectedError({ code: "INVALID_VALUE", property, reason });
50326
50888
  }
50327
50889
  function pickOption(value, allowed, property, fallback) {
@@ -50329,30 +50891,30 @@ function pickOption(value, allowed, property, fallback) {
50329
50891
  return fallback;
50330
50892
  if (typeof value === "string" && allowed.includes(value))
50331
50893
  return value;
50332
- return invalid(property, `expected one of ${allowed.join(", ")}`);
50894
+ return invalid2(property, `expected one of ${allowed.join(", ")}`);
50333
50895
  }
50334
50896
  function numberOption(value, property, fallback, positive = false) {
50335
50897
  if (value === undefined || value === null)
50336
50898
  return fallback;
50337
50899
  if (typeof value !== "number" || !Number.isFinite(value) || positive && value <= 0)
50338
- return invalid(property, positive ? "expected a positive number" : "expected a number");
50900
+ return invalid2(property, positive ? "expected a positive number" : "expected a number");
50339
50901
  return value;
50340
50902
  }
50341
- function optionKeys(value, allowed, name) {
50903
+ function optionKeys2(value, allowed, name) {
50342
50904
  if (value === undefined || value === null)
50343
50905
  return {};
50344
50906
  if (typeof value !== "object" || Array.isArray(value))
50345
- return invalid(name, "expected an options object");
50907
+ return invalid2(name, "expected an options object");
50346
50908
  for (const key of Object.keys(value))
50347
50909
  if (!allowed.has(key))
50348
- return invalid(key, `${name} does not take ${key}`);
50910
+ return invalid2(key, `${name} does not take ${key}`);
50349
50911
  return value;
50350
50912
  }
50351
50913
  function dashOption(value) {
50352
50914
  if (value === undefined || value === null)
50353
50915
  return;
50354
50916
  if (!Array.isArray(value) || !value.every((d) => typeof d === "number" && Number.isFinite(d) && d > 0))
50355
- invalid("dash", "expected an array of positive numbers");
50917
+ invalid2("dash", "expected an array of positive numbers");
50356
50918
  return value;
50357
50919
  }
50358
50920
  var LIMITS = { ops: 5000, printBytes: 64 * 1024, screenshots: 4, vectorize: 2 };
@@ -50406,6 +50968,8 @@ class ExecuteApi {
50406
50968
  document = "document";
50407
50969
  layoutCache = new Map;
50408
50970
  defaults = {};
50971
+ connectors = new Map;
50972
+ connectorsIndexed = false;
50409
50973
  constructor(store, rec, bounds, rev, random = Math.random, measureText, kits) {
50410
50974
  this.store = store;
50411
50975
  this.rec = rec;
@@ -50667,6 +51231,8 @@ class ExecuteApi {
50667
51231
  patch.descendants = { ...row.props.descendants ?? {}, ...this.resolveDescendantKeys(row.props.ref, patch.descendants) };
50668
51232
  this.warnProps({ ...patch, ...row.props.type === "ref" ? { ref: row.props.ref } : {} }, row.props.type, row.id);
50669
51233
  this.commit({ op: "update", id: row.id, patch });
51234
+ if (MOVING_KEYS.some((k) => (k in patch)) || patch.descendants && this.store.get(row.id))
51235
+ this.finalizeConnectors();
50670
51236
  }
50671
51237
  Replace(path, nodeData) {
50672
51238
  const inst = this.splitInstancePath(path);
@@ -50704,6 +51270,7 @@ class ExecuteApi {
50704
51270
  const before = i > 0 ? this.store.get(siblings[i - 1]).ord : null;
50705
51271
  const after = i < siblings.length ? this.store.get(siblings[i]).ord : null;
50706
51272
  this.commit({ op: "move", id: row.id, parent: p, ord: between(before, after) });
51273
+ this.finalizeConnectors();
50707
51274
  }
50708
51275
  Delete(path) {
50709
51276
  if (path === "document")
@@ -50713,6 +51280,7 @@ class ExecuteApi {
50713
51280
  if (!this.store.get(path))
50714
51281
  throw new OpRejectedError({ code: "NODE_NOT_FOUND", path });
50715
51282
  this.commit({ op: "delete", id: path });
51283
+ this.finalizeConnectors();
50716
51284
  }
50717
51285
  MoveToBack(path) {
50718
51286
  this.Move(path, undefined, 0);
@@ -50953,14 +51521,14 @@ class ExecuteApi {
50953
51521
  }
50954
51522
  MeasureText(content, options) {
50955
51523
  if (typeof content !== "string")
50956
- invalid("content", "expected a string");
51524
+ invalid2("content", "expected a string");
50957
51525
  if (!this.measureText)
50958
- invalid("MeasureText", "this host has no font set, so text cannot be measured");
50959
- const o = optionKeys(options, MEASURE_KEYS, "MeasureText");
51526
+ invalid2("MeasureText", "this host has no font set, so text cannot be measured");
51527
+ const o = optionKeys2(options, MEASURE_KEYS, "MeasureText");
50960
51528
  if (typeof o.fontFamily !== "string" || o.fontFamily === "")
50961
- invalid("fontFamily", "expected a font family name");
51529
+ invalid2("fontFamily", "expected a font family name");
50962
51530
  if (o.fontSize === undefined || o.fontSize === null)
50963
- invalid("fontSize", "expected a positive number");
51531
+ invalid2("fontSize", "expected a positive number");
50964
51532
  return this.measureText({
50965
51533
  content,
50966
51534
  fontFamily: o.fontFamily,
@@ -50976,59 +51544,45 @@ class ExecuteApi {
50976
51544
  }
50977
51545
  Connect(from, to, options) {
50978
51546
  if (typeof from !== "string" || typeof to !== "string")
50979
- invalid("from", "expected a node id");
51547
+ invalid2("from", "expected a node id");
50980
51548
  if (from === to)
50981
- invalid("to", "a node cannot be connected to itself");
51549
+ invalid2("to", "a node cannot be connected to itself");
50982
51550
  this.rowOf(from);
50983
51551
  this.rowOf(to);
50984
- const o = optionKeys(options, CONNECT_KEYS, "Connect");
50985
- if (o.route === "elbow")
50986
- invalid("route", "elbow routing is not available yet");
51552
+ const o = optionKeys2(options, CONNECT_KEYS, "Connect");
50987
51553
  const route = pickOption(o.route, ROUTES, "route", "straight");
50988
51554
  const fromMagnet = pickOption(o.fromMagnet, MAGNETS, "fromMagnet", "auto");
50989
51555
  const toMagnet = pickOption(o.toMagnet, MAGNETS, "toMagnet", "auto");
50990
51556
  const arrow = pickOption(o.arrow, ARROWS, "arrow", "end");
50991
51557
  const labelPos = numberOption(o.labelPos, "labelPos", 0.5);
50992
51558
  if (labelPos < 0 || labelPos > 1)
50993
- invalid("labelPos", "expected a number between 0 and 1");
51559
+ invalid2("labelPos", "expected a number between 0 and 1");
50994
51560
  const strokeWidth = numberOption(o.strokeWidth, "strokeWidth", 1.5, true);
50995
51561
  const stroke = o.stroke === undefined || o.stroke === null ? "#64748B" : o.stroke;
50996
51562
  if (typeof stroke !== "string")
50997
- invalid("stroke", "expected a colour string");
51563
+ invalid2("stroke", "expected a colour string");
50998
51564
  const dash = dashOption(o.dash);
50999
51565
  const behind = o.behind === undefined || o.behind === null ? true : o.behind;
51000
51566
  if (typeof behind !== "boolean")
51001
- invalid("behind", "expected a boolean");
51567
+ invalid2("behind", "expected a boolean");
51002
51568
  const name = o.name === undefined || o.name === null ? "Connector" : o.name;
51003
51569
  if (typeof name !== "string")
51004
- invalid("name", "expected a string");
51570
+ invalid2("name", "expected a string");
51005
51571
  if (o.label !== undefined && o.label !== null && typeof o.label !== "string")
51006
- invalid("label", "expected a string");
51007
- const geom = connectorGeometry(this.connectorEnd(from, "from"), this.connectorEnd(to, "to"), { route, fromMagnet, toMagnet, arrow, strokeWidth, labelPos, dash });
51572
+ invalid2("label", "expected a string");
51573
+ const ends = { from: this.connectorEnd(from, "from"), to: this.connectorEnd(to, "to") };
51574
+ const geom = connectorGeometry(ends.from, ends.to, { route, fromMagnet, toMagnet, arrow, strokeWidth, labelPos, dash });
51008
51575
  const parent = o.parent === undefined || o.parent === null ? this.commonParent(from, to) : this.parentId(String(o.parent));
51009
51576
  const target = parent ?? "document";
51010
51577
  const origin = this.originOf(parent);
51011
51578
  const absolute = this.inFlow(parent);
51012
51579
  const place = (box) => ({ x: box.x - origin.x, y: box.y - origin.y, width: box.width, height: box.height, ...absolute ? { layoutPosition: "absolute" } : {} });
51013
- const id = this.Insert(target, {
51014
- id: "",
51015
- type: "path",
51016
- name,
51017
- ...place(geom.bbox),
51018
- viewBox: [0, 0, geom.bbox.width, geom.bbox.height],
51019
- geometry: geom.geometry,
51020
- fill: stroke,
51021
- stroke,
51022
- strokeWidth,
51023
- metadata: { connector: { from, to, fromMagnet, toMagnet, route, arrow, labelPos } }
51024
- });
51025
- if (behind)
51026
- this.Move(id, target, 0);
51580
+ let labelId;
51027
51581
  if (typeof o.label === "string" && o.label !== "") {
51028
51582
  const size = this.MeasureText(o.label, { fontFamily: "Inter", fontSize: 12 });
51029
51583
  const width = size.width + 8;
51030
51584
  const height = size.height + 4;
51031
- this.Insert(target, {
51585
+ labelId = this.Insert(target, {
51032
51586
  id: "",
51033
51587
  type: "frame",
51034
51588
  name: `${name}-label`,
@@ -51039,8 +51593,139 @@ class ExecuteApi {
51039
51593
  children: [{ id: "", type: "text", x: 4, y: 2, content: o.label, fontFamily: "Inter", fontSize: 12, fill: "#334155" }]
51040
51594
  });
51041
51595
  }
51596
+ const id = this.Insert(target, {
51597
+ id: "",
51598
+ type: "path",
51599
+ name,
51600
+ ...place(geom.bbox),
51601
+ viewBox: [0, 0, geom.bbox.width, geom.bbox.height],
51602
+ geometry: geom.geometry,
51603
+ fill: stroke,
51604
+ stroke,
51605
+ strokeWidth,
51606
+ metadata: { connector: { from, to, fromMagnet, toMagnet, route, arrow, labelPos, ...dash ? { dash } : {}, ...labelId ? { labelId } : {} } }
51607
+ });
51608
+ this.connectors.set(id, { from, to, fromMagnet, toMagnet, route, arrow, labelPos, ...dash ? { dash } : {}, ...labelId ? { labelId } : {} });
51609
+ if (behind)
51610
+ this.Move(id, target, 0);
51611
+ this.warnConnector(id, geom);
51042
51612
  return id;
51043
51613
  }
51614
+ finalizeConnectors() {
51615
+ if (!this.mutations)
51616
+ return;
51617
+ for (const id of this.knownConnectors())
51618
+ this.redrawConnector(id);
51619
+ }
51620
+ knownConnectors() {
51621
+ if (!this.connectorsIndexed) {
51622
+ this.connectorsIndexed = true;
51623
+ const walk = (parent) => {
51624
+ for (const id of this.store.children(parent)) {
51625
+ const props = this.store.get(id)?.props;
51626
+ if (!props)
51627
+ continue;
51628
+ const meta = connectorMetaOf(props);
51629
+ if (meta && !this.connectors.has(id))
51630
+ this.connectors.set(id, meta);
51631
+ walk(id);
51632
+ }
51633
+ };
51634
+ walk(null);
51635
+ }
51636
+ return [...this.connectors.keys()];
51637
+ }
51638
+ redrawConnector(id) {
51639
+ const row = this.store.get(id);
51640
+ const meta = row ? connectorMetaOf(row.props) : null;
51641
+ if (!row || !meta) {
51642
+ this.connectors.delete(id);
51643
+ return;
51644
+ }
51645
+ const from = this.absoluteOf(meta.from);
51646
+ const to = this.absoluteOf(meta.to);
51647
+ if (!from || !to || from.width === 0 && from.height === 0 || to.width === 0 && to.height === 0) {
51648
+ this.warnOnce("CONNECTOR_ENDPOINT_GONE", id, `connector ${String(row.props.name ?? id)}: ${meta.from} or ${meta.to} is gone or has no laid-out box; the line was left where it was`);
51649
+ return;
51650
+ }
51651
+ const end = (box2, path) => {
51652
+ const props = this.store.get(path).props;
51653
+ return { box: box2, shape: String(props.type), cornerRadius: typeof props.cornerRadius === "number" ? props.cornerRadius : 0 };
51654
+ };
51655
+ const geom = connectorGeometry(end(from, meta.from), end(to, meta.to), {
51656
+ route: meta.route,
51657
+ fromMagnet: meta.fromMagnet,
51658
+ toMagnet: meta.toMagnet,
51659
+ arrow: meta.arrow,
51660
+ labelPos: meta.labelPos,
51661
+ dash: meta.dash,
51662
+ strokeWidth: typeof row.props.strokeWidth === "number" ? row.props.strokeWidth : 1.5
51663
+ });
51664
+ const origin = this.originOf(row.parent);
51665
+ const box = { x: geom.bbox.x - origin.x, y: geom.bbox.y - origin.y, width: geom.bbox.width, height: geom.bbox.height };
51666
+ const viewBox = [0, 0, geom.bbox.width, geom.bbox.height];
51667
+ const patch = {};
51668
+ for (const [key, value] of Object.entries({ ...box, viewBox, geometry: geom.geometry }))
51669
+ if (JSON.stringify(row.props[key]) !== JSON.stringify(value))
51670
+ patch[key] = value;
51671
+ if (Object.keys(patch).length)
51672
+ this.commit({ op: "update", id, patch });
51673
+ if (meta.labelId) {
51674
+ const label = this.store.get(meta.labelId);
51675
+ const labelBox = this.absoluteOf(meta.labelId);
51676
+ if (label && labelBox) {
51677
+ const x = geom.labelCenter.x - labelBox.width / 2 - origin.x;
51678
+ const y = geom.labelCenter.y - labelBox.height / 2 - origin.y;
51679
+ const labelPatch = {};
51680
+ if (label.props.x !== x)
51681
+ labelPatch.x = x;
51682
+ if (label.props.y !== y)
51683
+ labelPatch.y = y;
51684
+ if (Object.keys(labelPatch).length)
51685
+ this.commit({ op: "update", id: meta.labelId, patch: labelPatch });
51686
+ }
51687
+ }
51688
+ this.warnConnector(id, geom);
51689
+ }
51690
+ warnOnce(code, nodeId, message) {
51691
+ if (this.rec.warnings.length >= 20)
51692
+ return;
51693
+ if (this.rec.warnings.some((w) => w.code === code && w.nodeId === nodeId))
51694
+ return;
51695
+ this.rec.warnings.push({ code, nodeId, message });
51696
+ }
51697
+ warnConnector(id, geom) {
51698
+ const row = this.store.get(id);
51699
+ if (!row)
51700
+ return;
51701
+ const meta = connectorMetaOf(row.props);
51702
+ const labelIds = new Set;
51703
+ for (const m of this.connectors.values())
51704
+ if (m.labelId)
51705
+ labelIds.add(m.labelId);
51706
+ let labelBox = null;
51707
+ for (const sibling of this.store.children(row.parent)) {
51708
+ const props = this.store.get(sibling)?.props;
51709
+ if (!props || sibling === id)
51710
+ continue;
51711
+ const box = this.absoluteOf(sibling);
51712
+ if (!box || box.width === 0 && box.height === 0)
51713
+ continue;
51714
+ if (sibling === meta?.labelId) {
51715
+ labelBox = box;
51716
+ continue;
51717
+ }
51718
+ if (!labelIds.has(sibling) && !this.connectors.has(sibling) && sibling !== meta?.from && sibling !== meta?.to) {
51719
+ for (let i = 1;i < geom.polyline.length; i++)
51720
+ if (segmentCrossesBox(geom.polyline[i - 1], geom.polyline[i], box)) {
51721
+ this.warnOnce("CONNECTOR_CROSSES_NODE", id, `line crosses ${String(props.name ?? sibling)}`);
51722
+ break;
51723
+ }
51724
+ }
51725
+ if (labelBox && rectsOverlap(labelBox, box))
51726
+ this.warnOnce("LABEL_OVERLAP", id, `label overlaps ${String(props.name ?? sibling)}`);
51727
+ }
51728
+ }
51044
51729
  absoluteOf(path) {
51045
51730
  if (path === null || path === "")
51046
51731
  return { x: 0, y: 0, width: 0, height: 0 };
@@ -51055,14 +51740,14 @@ class ExecuteApi {
51055
51740
  return { x: 0, y: 0 };
51056
51741
  const box = this.absoluteOf(parent);
51057
51742
  if (!box)
51058
- invalid("parent", `${parent} has no laid-out box`);
51743
+ invalid2("parent", `${parent} has no laid-out box`);
51059
51744
  return { x: box.x, y: box.y };
51060
51745
  }
51061
51746
  connectorEnd(id, property) {
51062
51747
  const row = this.rowOf(id);
51063
51748
  const box = this.absoluteOf(id);
51064
51749
  if (!box || box.width === 0 && box.height === 0)
51065
- invalid(property, `${id} has no laid-out box to attach to`);
51750
+ invalid2(property, `${id} has no laid-out box to attach to`);
51066
51751
  return { box, shape: String(row.props.type), cornerRadius: typeof row.props.cornerRadius === "number" ? row.props.cornerRadius : 0 };
51067
51752
  }
51068
51753
  commonParent(a, b) {
@@ -51109,15 +51794,26 @@ class ExecuteApi {
51109
51794
  return { x: minX, y: maxY + pad };
51110
51795
  return { x: minX, y: minY - pad - input.height };
51111
51796
  }
51797
+ KitPlan(kind, options) {
51798
+ const variables = this.store.variables();
51799
+ return planKitNode(kind, options, {
51800
+ variables: new Set(Object.keys(variables)),
51801
+ measure: (request) => {
51802
+ const family = typeof request.fontFamily === "string" && request.fontFamily.startsWith("$") ? variables[request.fontFamily.slice(1)]?.value : request.fontFamily;
51803
+ const { content, ...options2 } = { ...request, fontFamily: typeof family === "string" && family !== "" ? family : "Geist" };
51804
+ return this.MeasureText(content, options2);
51805
+ }
51806
+ });
51807
+ }
51112
51808
  ListKits() {
51113
51809
  return this.kits?.list() ?? [];
51114
51810
  }
51115
51811
  UseKit(name) {
51116
51812
  if (typeof name !== "string" || name === "")
51117
- invalid("name", "expected a kit name");
51813
+ invalid2("name", "expected a kit name");
51118
51814
  const entry = this.kits?.get(name);
51119
51815
  if (!entry)
51120
- invalid("name", `unknown kit ${JSON.stringify(name)}; available: ${this.kits?.names().join(", ") || "none"}`);
51816
+ invalid2("name", `unknown kit ${JSON.stringify(name)}; available: ${this.kits?.names().join(", ") || "none"}`);
51121
51817
  const plan = planKit(existingKitNodesIn(this.store, entry.kit.name), entry.kit);
51122
51818
  const { refs, ids } = planRefs(plan);
51123
51819
  for (const ref of refs)
@@ -51175,17 +51871,17 @@ class ExecuteApi {
51175
51871
  }
51176
51872
  Vectorize(frameId, fileId, opts) {
51177
51873
  if (typeof frameId !== "string" || frameId === "")
51178
- invalid("frameId", "expected a frame id");
51874
+ invalid2("frameId", "expected a frame id");
51179
51875
  if (typeof fileId !== "string" || fileId === "")
51180
- invalid("fileId", "expected a file id");
51181
- const options = optionKeys(opts, VECTORIZE_KEYS, "Vectorize");
51876
+ invalid2("fileId", "expected a file id");
51877
+ const options = optionKeys2(opts, VECTORIZE_KEYS, "Vectorize");
51182
51878
  const mode = options.mode === undefined || options.mode === null ? undefined : pickOption(options.mode, VECTORIZE_MODES, "mode", "auto");
51183
51879
  const maxColors = options.maxColors === undefined || options.maxColors === null ? undefined : options.maxColors;
51184
51880
  if (maxColors !== undefined && (typeof maxColors !== "number" || !Number.isInteger(maxColors) || maxColors < 1))
51185
- invalid("maxColors", "expected a positive integer");
51881
+ invalid2("maxColors", "expected a positive integer");
51186
51882
  const allowComplex = options.allowComplex === undefined || options.allowComplex === null ? undefined : options.allowComplex;
51187
51883
  if (allowComplex !== undefined && typeof allowComplex !== "boolean")
51188
- invalid("allowComplex", "expected a boolean");
51884
+ invalid2("allowComplex", "expected a boolean");
51189
51885
  if (this.rec.pendingVectorize.length >= LIMITS.vectorize)
51190
51886
  throw new Error(`SCRIPT_LIMIT: at most ${LIMITS.vectorize} Vectorize calls in one execute — ask for one image per execute, or trace one combined image`);
51191
51887
  const requestId = this.newRequestId();
@@ -52154,7 +52850,7 @@ function startProgress(ctx, write = (text) => writeOutput({ stderr: text })) {
52154
52850
  }
52155
52851
 
52156
52852
  // src/main.ts
52157
- var version = "0.3.0-dev.2615392";
52853
+ var version = "0.3.0-dev.27abe4e";
52158
52854
  var commands = commandTree(operations);
52159
52855
  var manual = [...workflows.map((w) => w.words), [API_WORD]];
52160
52856
  function route(argv) {
@@ -52408,16 +53104,16 @@ Examples:
52408
53104
  const cursor = result instanceof Page ? result.next_cursor : record(result).next_cursor ?? record(result).nextToken;
52409
53105
  if (typeof cursor === "string" && cursor)
52410
53106
  ctx.nextCommand = nextPageCommand(selected.command, parsed, cursor);
52411
- const pageToken = pageTokenField(op), token = pageToken?.sdkName ?? pageToken?.name;
52412
- const firstPage = flags.all && !(result instanceof Page) && token ? pageOf(result) : undefined;
52413
- if (flags.all && !(result instanceof Page) && token && !firstPage)
52414
- throw new UsageError(`--all cannot find the list in ${op.resource}.${op.method}'s response; page with --${token.replace(/_/g, "-")} instead`);
53107
+ const pageToken = pageTokenField(op), token2 = pageToken?.sdkName ?? pageToken?.name;
53108
+ const firstPage = flags.all && !(result instanceof Page) && token2 ? pageOf(result) : undefined;
53109
+ if (flags.all && !(result instanceof Page) && token2 && !firstPage)
53110
+ throw new UsageError(`--all cannot find the list in ${op.resource}.${op.method}'s response; page with --${token2.replace(/_/g, "-")} instead`);
52415
53111
  if (firstPage) {
52416
53112
  const items = [...firstPage.items];
52417
53113
  const seen = new Set;
52418
53114
  for (let next = firstPage.token;next && !seen.has(next); next = pageOf(result)?.token) {
52419
53115
  seen.add(next);
52420
- result = await owner[op.method]({ ...opts, query: { ...opts.query, [token]: next } });
53116
+ result = await owner[op.method]({ ...opts, query: { ...opts.query, [token2]: next } });
52421
53117
  items.push(...pageOf(result)?.items ?? []);
52422
53118
  }
52423
53119
  ctx.nextCommand = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepraxis/cli",
3
- "version": "0.3.0-dev.2615392",
3
+ "version": "0.3.0-dev.27abe4e",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "praxis": "dist/praxis.js"