@deepraxis/cli 0.3.0-dev.2615392 → 0.3.0-dev.40e3123

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
+ 675 HTTP operations; 677 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,17 @@ 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
225
  | `praxis api browser session get <sessionId>` | `browser.sessions.retrieve` | GET `/browser/v1/sessions/{sessionId}` | `--expand` |
226
226
  | `praxis api browser session get-debug <sessionId>` | `browser.sessions.retrieveDebug` | GET `/browser/v1/sessions/{sessionId}/debug` | |
227
+ | `praxis api browser session get-frame <sessionId>` | `browser.sessions.retrieveFrame` | GET `/browser/v1/sessions/{sessionId}/frame` | |
227
228
  | `praxis api browser session handoff complete` | `browser.sessions.handoff.complete` | POST `/browser/v1/sessions/{sessionId}/handoff/complete` | `--session` |
228
229
  | `praxis api browser session handoff create` | `browser.sessions.handoff.create` | POST `/browser/v1/sessions/{sessionId}/handoff` | `--session`, `--message`, `--timeout-ms` |
229
230
  | `praxis api browser session list` | `browser.sessions.list` | GET `/browser/v1/sessions` | `--status`, `--name`, `--labels`, `--param-cursor`, `--param-limit` |
230
231
  | `praxis api browser session stream <sessionId>` | `browser.sessions.stream` | GET `/browser/v1/sessions/{sessionId}/stream` | |
231
232
  | `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` |
233
+ | `praxis api browser session viewer create` | `browser.sessions.viewer.create` | POST `/browser/v1/sessions/{sessionId}/viewer` | `--session`, `--viewer-id`, `--kind` |
233
234
  | `praxis api canvas canvase create` | `canvas.canvases.create` | POST `/canvas/v1/canvases` | `--name` |
234
235
  | `praxis api canvas canvase delete <canvas_id>` | `canvas.canvases.delete` | DELETE `/canvas/v1/canvases/{canvas_id}` | |
235
236
  | `praxis api canvas canvase execute <canvas_id>` | `canvas.canvases.execute` | POST `/canvas/v1/canvases/{canvas_id}:execute` | `--script`, `--edit-id`, `--expected-version` |
@@ -562,11 +563,11 @@ Handwritten commands: `login`, `logout`, `whoami`, `org list`, `org switch <orga
562
563
  | `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
564
  | `praxis api studio codex create` | `studio.codexes.create` | POST `/studio/v1/codexes` | `--name`, `--description` |
564
565
  | `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` |
566
+ | `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
567
  | `praxis api studio codex entry delete <entry>` | `studio.codexes.entries.delete` | DELETE `/studio/v1/codexes/{codex}/entries/{entry}` | `--codex` |
567
568
  | `praxis api studio codex entry get <entry>` | `studio.codexes.entries.retrieve` | GET `/studio/v1/codexes/{codex}/entries/{entry}` | `--codex` |
568
569
  | `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` |
570
+ | `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
571
  | `praxis api studio codex get <codex>` | `studio.codexes.retrieve` | GET `/studio/v1/codexes/{codex}` | |
571
572
  | `praxis api studio codex list` | `studio.codexes.list` | GET `/studio/v1/codexes` | `--page-size`, `--page-token` |
572
573
  | `praxis api studio codex update <codex>` | `studio.codexes.update` | PATCH `/studio/v1/codexes/{codex}` | `--update-mask`, `--name`, `--description` |
@@ -662,6 +663,7 @@ Handwritten commands: `login`, `logout`, `whoami`, `org list`, `org switch <orga
662
663
  | `praxis api ticket relation delete <n>` | `ticket.tickets.relations.delete` | DELETE `/ticket/v1/tickets/{number}/relations/{n}` | `--ticket`, `--repository` |
663
664
  | `praxis api ticket relation list` | `ticket.tickets.relations.list` | GET `/ticket/v1/tickets/{number}/relations` | `--ticket`, `--repository`, `--page-size`, `--page-token` |
664
665
  | `praxis api ticket repository list` | `ticket.repositories.list` | GET `/ticket/v1/repositories` | `--page-size`, `--page-token` |
666
+ | `praxis api ticket repository update <id>` | `ticket.repositories.update` | PATCH `/ticket/v1/repositories/{id}` | `--repository` |
665
667
  | `praxis api ticket sub-ticket create` | `ticket.tickets.subTickets.create` | POST `/ticket/v1/tickets/{number}/sub_tickets` | `--ticket`, `--repository`, `--child`, `--replace-parent` |
666
668
  | `praxis api ticket sub-ticket delete <child>` | `ticket.tickets.subTickets.delete` | DELETE `/ticket/v1/tickets/{number}/sub_tickets/{child}` | `--ticket`, `--repository` |
667
669
  | `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,24 @@ 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
+ },
14506
14534
  {
14507
14535
  resource: "browser.sessions.handoff",
14508
14536
  method: "create",
@@ -14599,6 +14627,16 @@ file at the root of that directory.`
14599
14627
  type: "string",
14600
14628
  required: true,
14601
14629
  description: "当前观看者的稳定标识;同一观看者重复心跳应使用相同值,长度为 1–128 个 UTF-16 代码单元。"
14630
+ },
14631
+ {
14632
+ name: "kind",
14633
+ type: "string",
14634
+ enum: [
14635
+ "control",
14636
+ "readonly"
14637
+ ],
14638
+ required: false,
14639
+ description: "观看者类型:control 是需要控制浏览器的客户端,readonly 是只读观看者。只读观看者发送 control 也会按 readonly 记录。"
14602
14640
  }
14603
14641
  ]
14604
14642
  }
@@ -32273,6 +32311,31 @@ for more details.`
32273
32311
  }
32274
32312
  ]
32275
32313
  },
32314
+ {
32315
+ resource: "ticket.repositories",
32316
+ method: "update",
32317
+ summary: "Update repositories",
32318
+ 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.",
32319
+ http: "PATCH",
32320
+ path: "/ticket/v1/repositories/{id}",
32321
+ streaming: "no",
32322
+ pagination: false,
32323
+ pathParams: [
32324
+ {
32325
+ name: "id",
32326
+ sdkName: "id",
32327
+ description: "Identifier returned by the matching create or list operation; number paths take repository-local numbers."
32328
+ }
32329
+ ],
32330
+ query: [
32331
+ {
32332
+ name: "repository",
32333
+ type: "string",
32334
+ required: false,
32335
+ description: "Repository id from GET /ticket/v1/repositories; omit for the default tickets container."
32336
+ }
32337
+ ]
32338
+ },
32276
32339
  {
32277
32340
  resource: "ticket.tickets",
32278
32341
  method: "list",
@@ -35692,6 +35755,15 @@ var browserViewerHeartbeat = (options) => (options.client ?? client).post({
35692
35755
  ...options.headers
35693
35756
  }
35694
35757
  });
35758
+ var browserGetSessionFrame = (options) => (options.client ?? client).get({
35759
+ security: [{
35760
+ key: "BrowserBearer",
35761
+ scheme: "bearer",
35762
+ type: "http"
35763
+ }],
35764
+ url: "/browser/v1/sessions/{sessionId}/frame",
35765
+ ...options
35766
+ });
35695
35767
  var browserListContexts = (options) => (options?.client ?? client).get({
35696
35768
  security: [{
35697
35769
  key: "BrowserBearer",
@@ -44199,6 +44271,19 @@ var ticketGetRepositories = (options) => (options?.client ?? client).get({
44199
44271
  url: "/ticket/v1/repositories",
44200
44272
  ...options
44201
44273
  });
44274
+ var ticketPatchRepositoriesId = (options) => (options.client ?? client).patch({
44275
+ security: [{
44276
+ key: "BearerAuth",
44277
+ scheme: "bearer",
44278
+ type: "http"
44279
+ }, {
44280
+ key: "ApiKeyAuth",
44281
+ name: "X-API-Key",
44282
+ type: "apiKey"
44283
+ }],
44284
+ url: "/ticket/v1/repositories/{id}",
44285
+ ...options
44286
+ });
44202
44287
 
44203
44288
  // ../../packages/sdk/typescript/src/core/pagination.ts
44204
44289
  class Page {
@@ -44653,6 +44738,7 @@ function createBrowser(transport) {
44653
44738
  list: bind(transport, browserListSessions),
44654
44739
  retrieve: bind(transport, browserGetSession),
44655
44740
  retrieveDebug: bind(transport, browserGetDebug),
44741
+ retrieveFrame: bind(transport, browserGetSessionFrame),
44656
44742
  stream: bindStream(transport, browserStreamSession),
44657
44743
  update: bind(transport, browserCloseSession),
44658
44744
  viewer: {
@@ -45492,7 +45578,8 @@ function createTicket(transport) {
45492
45578
  update: bind(transport, ticketPatchMilestonesNumber)
45493
45579
  },
45494
45580
  repositories: {
45495
- list: bind(transport, ticketGetRepositories)
45581
+ list: bind(transport, ticketGetRepositories),
45582
+ update: bind(transport, ticketPatchRepositoriesId)
45496
45583
  },
45497
45584
  tickets: {
45498
45585
  comments: {
@@ -49781,7 +49868,7 @@ function retop(store, id, top, rev) {
49781
49868
  // ../../packages/canvas/document/src/connector.ts
49782
49869
  var MAGNETS = ["auto", "center", "top", "right", "bottom", "left"];
49783
49870
  var ARROWS = ["end", "start", "both", "none"];
49784
- var ROUTES = ["straight"];
49871
+ var ROUTES = ["straight", "elbow"];
49785
49872
  var ARROW_LENGTH_FACTOR = 6;
49786
49873
  var ARROW_HALF_ANGLE_DEG = 25;
49787
49874
  var EPSILON = 0.000000001;
@@ -49869,6 +49956,30 @@ function normalize(p) {
49869
49956
  const l = Math.hypot(p.x, p.y);
49870
49957
  return { x: p.x / l, y: p.y / l };
49871
49958
  }
49959
+ function rectsOverlap(a, b) {
49960
+ 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;
49961
+ }
49962
+ function segmentCrossesBox(a, b, box) {
49963
+ const shrink = 0.000001;
49964
+ const dx = b.x - a.x;
49965
+ const dy = b.y - a.y;
49966
+ let t0 = 0;
49967
+ let t1 = 1;
49968
+ const slab = (start, delta, min, max) => {
49969
+ if (Math.abs(delta) < 0.000000000001)
49970
+ return start > min && start < max;
49971
+ const ta = (min - start) / delta;
49972
+ const tb = (max - start) / delta;
49973
+ t0 = Math.max(t0, Math.min(ta, tb));
49974
+ t1 = Math.min(t1, Math.max(ta, tb));
49975
+ return t0 <= t1;
49976
+ };
49977
+ if (!slab(a.x, dx, box.x + shrink, box.x + box.width - shrink))
49978
+ return false;
49979
+ if (!slab(a.y, dy, box.y + shrink, box.y + box.height - shrink))
49980
+ return false;
49981
+ return t1 > t0;
49982
+ }
49872
49983
  function dashRanges(length, dash) {
49873
49984
  const pattern = (dash ?? []).filter((d) => typeof d === "number" && Number.isFinite(d) && d > 0);
49874
49985
  if (!pattern.length)
@@ -49890,40 +50001,105 @@ function n(value) {
49890
50001
  const rounded = Math.round(value * 100) / 100;
49891
50002
  return String(Object.is(rounded, -0) ? 0 : rounded);
49892
50003
  }
50004
+ var isHorizontal = (side) => side === "left" || side === "right";
50005
+ function elbowPath(from, to, fromMagnet, toMagnet) {
50006
+ if (fromMagnet === "center" || toMagnet === "center")
50007
+ throw new OpRejectedError({
50008
+ code: "INVALID_VALUE",
50009
+ property: fromMagnet === "center" ? "fromMagnet" : "toMagnet",
50010
+ reason: "elbow routing needs an edge, not the centre"
50011
+ });
50012
+ const dx = centerOf(to.box).x - centerOf(from.box).x;
50013
+ const dy = centerOf(to.box).y - centerOf(from.box).y;
50014
+ const across = Math.abs(dx) > Math.abs(dy);
50015
+ const fromSide = fromMagnet === "auto" ? across ? dx > 0 ? "right" : "left" : dy > 0 ? "bottom" : "top" : fromMagnet;
50016
+ const toSide = toMagnet === "auto" ? across ? dx > 0 ? "left" : "right" : dy > 0 ? "top" : "bottom" : toMagnet;
50017
+ const p1 = magnetPoint(from.box, fromSide);
50018
+ const p2 = magnetPoint(to.box, toSide);
50019
+ const out = [p1];
50020
+ if (isHorizontal(fromSide) === isHorizontal(toSide)) {
50021
+ if (isHorizontal(fromSide)) {
50022
+ const midX = (p1.x + p2.x) / 2;
50023
+ out.push({ x: midX, y: p1.y }, { x: midX, y: p2.y });
50024
+ } else {
50025
+ const midY = (p1.y + p2.y) / 2;
50026
+ out.push({ x: p1.x, y: midY }, { x: p2.x, y: midY });
50027
+ }
50028
+ } else {
50029
+ out.push(isHorizontal(fromSide) ? { x: p2.x, y: p1.y } : { x: p1.x, y: p2.y });
50030
+ }
50031
+ out.push(p2);
50032
+ const kept = [];
50033
+ for (const p of out) {
50034
+ const last = kept[kept.length - 1];
50035
+ if (last && last.x === p.x && last.y === p.y)
50036
+ continue;
50037
+ if (last && kept.length >= 2) {
50038
+ const before = kept[kept.length - 2];
50039
+ if (before.x === last.x && last.x === p.x || before.y === last.y && last.y === p.y)
50040
+ kept.pop();
50041
+ }
50042
+ kept.push(p);
50043
+ }
50044
+ return kept;
50045
+ }
50046
+ function cumulative(points) {
50047
+ const cum = [0];
50048
+ for (let i = 1;i < points.length; i++)
50049
+ cum.push(cum[i - 1] + Math.hypot(points[i].x - points[i - 1].x, points[i].y - points[i - 1].y));
50050
+ return cum;
50051
+ }
50052
+ function pointAt(points, cum, s) {
50053
+ const total = cum[cum.length - 1];
50054
+ const at = Math.max(0, Math.min(s, total));
50055
+ let i = 0;
50056
+ while (i < points.length - 2 && cum[i + 1] < at)
50057
+ i++;
50058
+ const span = cum[i + 1] - cum[i];
50059
+ const f = span < EPSILON ? 0 : (at - cum[i]) / span;
50060
+ const a = points[i];
50061
+ const b = points[i + 1];
50062
+ return { x: a.x + (b.x - a.x) * f, y: a.y + (b.y - a.y) * f };
50063
+ }
49893
50064
  function connectorGeometry(from, to, opts = {}) {
49894
50065
  const arrow = opts.arrow ?? "end";
49895
50066
  const strokeWidth = opts.strokeWidth ?? 1.5;
49896
50067
  const labelPos = opts.labelPos ?? 0.5;
49897
50068
  const fromMagnet = opts.fromMagnet ?? "auto";
49898
50069
  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);
50070
+ if (rectsOverlap(from.box, to.box))
50071
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "from", reason: "nodes overlap" });
50072
+ const points = (opts.route ?? "straight") === "elbow" ? elbowPath(from, to, fromMagnet, toMagnet) : [endPoint(from, fromMagnet, centerOf(to.box)), endPoint(to, toMagnet, centerOf(from.box))];
50073
+ const cum = cumulative(points);
50074
+ const length = cum[cum.length - 1];
50075
+ const p1 = points[0];
50076
+ const p2 = points[points.length - 1];
49904
50077
  if (length < EPSILON || inside(p1, to.box) || inside(p2, from.box))
49905
50078
  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 };
50079
+ const dir1 = normalize({ x: points[1].x - p1.x, y: points[1].y - p1.y });
50080
+ const dir2 = normalize({ x: p2.x - points[points.length - 2].x, y: p2.y - points[points.length - 2].y });
50081
+ const back = { x: -dir2.x, y: -dir2.y };
49908
50082
  const arrowHeads = [];
49909
50083
  if (arrow === "end" || arrow === "both")
49910
50084
  arrowHeads.push(arrowHead(p2, back, strokeWidth));
49911
50085
  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];
50086
+ arrowHeads.push(arrowHead(p1, dir1, strokeWidth));
50087
+ const xs = points.map((p) => p.x);
50088
+ const ys = points.map((p) => p.y);
49915
50089
  for (const head of arrowHeads) {
49916
50090
  xs.push(head.tip.x, head.left.x, head.right.x);
49917
50091
  ys.push(head.tip.y, head.left.y, head.right.y);
49918
50092
  }
49919
50093
  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
50094
  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
50095
  const parts = [];
49923
50096
  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)}`);
50097
+ const run = [pointAt(points, cum, start)];
50098
+ for (let i = 1;i < points.length - 1; i++)
50099
+ if (cum[i] > start + EPSILON && cum[i] < end - EPSILON)
50100
+ run.push(points[i]);
50101
+ run.push(pointAt(points, cum, end));
50102
+ parts.push(run.map((p, i) => `${i ? "L" : "M"}${n(local(p).x)} ${n(local(p).y)}`).join(""));
49927
50103
  }
49928
50104
  for (const head of arrowHeads) {
49929
50105
  const t = local(head.tip);
@@ -49931,7 +50107,7 @@ function connectorGeometry(from, to, opts = {}) {
49931
50107
  const r = local(head.right);
49932
50108
  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
50109
  }
49934
- return { points: [p1, p2], arrowHeads, bbox, labelCenter: at(labelPos), geometry: parts.join("") };
50110
+ return { points: [p1, p2], polyline: points, arrowHeads, bbox, labelCenter: pointAt(points, cum, labelPos * length), geometry: parts.join("") };
49935
50111
  }
49936
50112
  // ../../packages/canvas/document/src/expand.ts
49937
50113
  function defaultTheme(themes) {
@@ -50318,10 +50494,368 @@ function planRefs(plan) {
50318
50494
  return { refs, ids };
50319
50495
  }
50320
50496
 
50497
+ // ../../packages/canvas/document/src/kit-builders.ts
50498
+ var PRAXIS_UI_LITERALS = {
50499
+ "v3-surface-2": "#F1F3F2",
50500
+ "v3-border": "#E3E7E4",
50501
+ "v3-border-strong": "#CDD3CF",
50502
+ "v3-fg": "#0D1310",
50503
+ "v3-fg-2": "#4A5550",
50504
+ "v3-fg-3": "#6E7872",
50505
+ "v3-green-50": "#EEFBF3",
50506
+ "v3-green-700": "#167A43",
50507
+ "v3-code-bg": "#0F1512",
50508
+ "v3-code-fg": "#D6E2DB",
50509
+ "v3-danger": "#D92D20",
50510
+ "v3-danger-soft": "#FEF0EE",
50511
+ "v3-warning": "#C76A00",
50512
+ "v3-warning-soft": "#FFF6E5",
50513
+ "v3-info": "#2563EB",
50514
+ "v3-info-soft": "#EEF4FF",
50515
+ "v3-font": "Geist",
50516
+ "v3-mono": "Geist Mono",
50517
+ "r-md": 8
50518
+ };
50519
+ function token(ctx, name) {
50520
+ return ctx.variables.has(name) ? `$${name}` : PRAXIS_UI_LITERALS[name];
50521
+ }
50522
+ var KIT_LIMITS = {
50523
+ tableRows: 200,
50524
+ codeLines: 200,
50525
+ keyWidth: 240,
50526
+ minColumn: 24
50527
+ };
50528
+ var COLUMN_GAP = 12;
50529
+ var ROW_PADDING = 10;
50530
+ var BODY_SIZE = 13;
50531
+ var HEADER_SIZE = 12;
50532
+ function invalid(property, reason) {
50533
+ throw new OpRejectedError({ code: "INVALID_VALUE", property, reason });
50534
+ }
50535
+ function optionKeys(value, allowed, name) {
50536
+ if (value === undefined || value === null)
50537
+ return {};
50538
+ if (typeof value !== "object" || Array.isArray(value))
50539
+ return invalid(name, "expected an options object");
50540
+ for (const key of Object.keys(value))
50541
+ if (!allowed.includes(key))
50542
+ return invalid(key, `${name} does not take ${key}`);
50543
+ return value;
50544
+ }
50545
+ function requiredString(value, property) {
50546
+ if (typeof value !== "string" || value === "")
50547
+ return invalid(property, "expected a non-empty string");
50548
+ return value;
50549
+ }
50550
+ function optionalString(value, property) {
50551
+ if (value === undefined || value === null)
50552
+ return;
50553
+ return requiredString(value, property);
50554
+ }
50555
+ function containerWidth(value, property) {
50556
+ if (value === undefined || value === null || value === "fill_container")
50557
+ return "fill_container";
50558
+ if (typeof value === "number" && Number.isFinite(value) && value > 0)
50559
+ return value;
50560
+ return invalid(property, 'expected a positive number or "fill_container"');
50561
+ }
50562
+ var TABLE_KEYS = ["columns", "rows", "zebra", "width"];
50563
+ var COLUMN_KEYS = ["key", "title", "width", "align"];
50564
+ var requestOf = (width) => typeof width === "number" ? width : KIT_LIMITS.minColumn;
50565
+ function planColumns(columns, total, gap = COLUMN_GAP) {
50566
+ const fills = columns.filter((c) => typeof c.width !== "number").length;
50567
+ if (total === null)
50568
+ return columns.map((c) => typeof c.width === "number" ? c.width : "fill_container");
50569
+ const available = Math.max(0, total - gap * Math.max(0, columns.length - 1));
50570
+ const pinned = columns.reduce((sum, c) => sum + (typeof c.width === "number" ? c.width : 0), 0);
50571
+ const leftover = available - pinned;
50572
+ if (leftover > 0) {
50573
+ if (!fills)
50574
+ return columns.map((c) => c.width);
50575
+ const share = round2(leftover / fills);
50576
+ return columns.map((c) => typeof c.width === "number" ? c.width : share);
50577
+ }
50578
+ const requested = columns.reduce((sum, c) => sum + requestOf(c.width), 0);
50579
+ const scale = requested > 0 ? available / requested : 1;
50580
+ return columns.map((c) => Math.max(1, round2(requestOf(c.width) * scale)));
50581
+ }
50582
+ var round2 = (n2) => Math.round(n2 * 100) / 100;
50583
+ function cellRow(name, cells) {
50584
+ return { type: "frame", name, layout: "horizontal", gap: COLUMN_GAP, padding: [ROW_PADDING, 0], width: "fill_container", children: cells };
50585
+ }
50586
+ function planTable(options, ctx) {
50587
+ const o = optionKeys(options, TABLE_KEYS, "Kit.Table");
50588
+ if (!Array.isArray(o.columns) || o.columns.length === 0)
50589
+ invalid("columns", "expected a non-empty array of { key, title }");
50590
+ const rows = o.rows;
50591
+ if (!Array.isArray(rows))
50592
+ invalid("rows", "expected an array of row objects");
50593
+ if (rows.length > KIT_LIMITS.tableRows)
50594
+ invalid("rows", `${rows.length} rows; a table renders at most ${KIT_LIMITS.tableRows} — split it, or build the frame by hand`);
50595
+ const columns = o.columns.map((raw, i) => {
50596
+ const c = optionKeys(raw, COLUMN_KEYS, `columns[${i}]`);
50597
+ const width2 = c.width;
50598
+ if (width2 !== undefined && width2 !== null && width2 !== "fill" && !(typeof width2 === "number" && Number.isFinite(width2) && width2 > 0))
50599
+ invalid(`columns[${i}].width`, 'expected a positive number or "fill"');
50600
+ const align = c.align;
50601
+ if (align !== undefined && align !== null && align !== "left" && align !== "right")
50602
+ invalid(`columns[${i}].align`, 'expected "left" or "right"');
50603
+ return { key: requiredString(c.key, `columns[${i}].key`), title: requiredString(c.title, `columns[${i}].title`), width: width2, align };
50604
+ });
50605
+ const width = containerWidth(o.width, "width");
50606
+ const widths = planColumns(columns, typeof width === "number" ? width : null, COLUMN_GAP);
50607
+ const font = token(ctx, "v3-font");
50608
+ const headerCell = (title, w, align) => ({
50609
+ type: "text",
50610
+ name: title,
50611
+ content: title,
50612
+ width: w,
50613
+ textGrowth: "fixed-width",
50614
+ fontFamily: font,
50615
+ fontSize: HEADER_SIZE,
50616
+ fontWeight: 600,
50617
+ fill: token(ctx, "v3-fg-2"),
50618
+ ...align === "right" ? { textAlign: "right" } : {}
50619
+ });
50620
+ const dataCell = (title, content, w, align) => ({
50621
+ type: "text",
50622
+ name: title,
50623
+ content,
50624
+ width: w,
50625
+ textGrowth: "fixed-width",
50626
+ fontFamily: font,
50627
+ fontSize: BODY_SIZE,
50628
+ fill: token(ctx, "v3-fg"),
50629
+ ...align === "right" ? { textAlign: "right" } : {}
50630
+ });
50631
+ const children = [
50632
+ {
50633
+ type: "frame",
50634
+ name: "Header",
50635
+ layout: "vertical",
50636
+ gap: 0,
50637
+ width: "fill_container",
50638
+ stroke: token(ctx, "v3-border-strong"),
50639
+ strokeWidth: { bottom: 1 },
50640
+ strokeAlignment: "inner",
50641
+ children: [cellRow("HeaderRow", columns.map((c, i) => headerCell(c.title, widths[i], c.align)))]
50642
+ }
50643
+ ];
50644
+ rows.forEach((row, i) => {
50645
+ const record = row && typeof row === "object" && !Array.isArray(row) ? row : {};
50646
+ children.push({
50647
+ type: "frame",
50648
+ name: "Row",
50649
+ layout: "vertical",
50650
+ gap: 0,
50651
+ width: "fill_container",
50652
+ stroke: token(ctx, "v3-border"),
50653
+ strokeWidth: { bottom: 1 },
50654
+ strokeAlignment: "inner",
50655
+ ...o.zebra === true && i % 2 === 1 ? { fill: token(ctx, "v3-surface-2") } : {},
50656
+ children: [cellRow("RowCells", columns.map((c, j) => dataCell(c.key, textOf(record[c.key]), widths[j], c.align)))]
50657
+ });
50658
+ });
50659
+ return { type: "frame", name: "Table", layout: "vertical", gap: 0, width, children };
50660
+ }
50661
+ function textOf(value) {
50662
+ if (value === undefined || value === null)
50663
+ return "";
50664
+ return typeof value === "string" ? value : String(value);
50665
+ }
50666
+ function requiredText(value, property) {
50667
+ if (typeof value !== "string" && typeof value !== "number")
50668
+ return invalid(property, "expected a string or number");
50669
+ return String(value);
50670
+ }
50671
+ var CALLOUT_KEYS = ["tone", "title", "body"];
50672
+ var CALLOUT_TONES = {
50673
+ info: { soft: "v3-info-soft", ink: "v3-info" },
50674
+ success: { soft: "v3-green-50", ink: "v3-green-700" },
50675
+ warning: { soft: "v3-warning-soft", ink: "v3-warning" },
50676
+ danger: { soft: "v3-danger-soft", ink: "v3-danger" }
50677
+ };
50678
+ function planCallout(options, ctx) {
50679
+ const o = optionKeys(options, CALLOUT_KEYS, "Kit.Callout");
50680
+ const tone = o.tone;
50681
+ if (typeof tone !== "string" || !Object.hasOwn(CALLOUT_TONES, tone))
50682
+ invalid("tone", `expected one of ${Object.keys(CALLOUT_TONES).join(", ")}`);
50683
+ const body = requiredString(o.body, "body");
50684
+ const title = optionalString(o.title, "title");
50685
+ const pair = CALLOUT_TONES[tone];
50686
+ const font = token(ctx, "v3-font");
50687
+ const bodyChildren = [];
50688
+ if (title !== undefined)
50689
+ bodyChildren.push({ type: "text", name: "Title", content: title, fontFamily: font, fontSize: BODY_SIZE, fontWeight: 600, fill: token(ctx, pair.ink) });
50690
+ bodyChildren.push({
50691
+ type: "text",
50692
+ name: "Body",
50693
+ content: body,
50694
+ fontFamily: font,
50695
+ fontSize: BODY_SIZE,
50696
+ lineHeight: 1.5,
50697
+ width: "fill_container",
50698
+ textGrowth: "fixed-width",
50699
+ fill: token(ctx, "v3-fg")
50700
+ });
50701
+ return {
50702
+ type: "frame",
50703
+ name: "Callout",
50704
+ layout: "horizontal",
50705
+ gap: 0,
50706
+ width: "fill_container",
50707
+ fill: token(ctx, pair.soft),
50708
+ cornerRadius: token(ctx, "r-md"),
50709
+ clip: true,
50710
+ children: [
50711
+ { type: "rectangle", name: "Bar", width: 3, height: "fill_container", fill: token(ctx, pair.ink) },
50712
+ { type: "frame", name: "Content", layout: "vertical", gap: 6, padding: [12, 14], width: "fill_container", children: bodyChildren }
50713
+ ]
50714
+ };
50715
+ }
50716
+ var CODE_KEYS = ["lang", "text"];
50717
+ function planCode(options, ctx) {
50718
+ const o = optionKeys(options, CODE_KEYS, "Kit.Code");
50719
+ const lang = optionalString(o.lang, "lang");
50720
+ const text = requiredString(o.text, "text");
50721
+ const lines = text.split(`
50722
+ `);
50723
+ const shown = lines.length > KIT_LIMITS.codeLines ? [...lines.slice(0, KIT_LIMITS.codeLines), `… ${lines.length - KIT_LIMITS.codeLines} more lines`] : lines;
50724
+ const children = [];
50725
+ if (lang !== undefined)
50726
+ children.push({
50727
+ type: "text",
50728
+ name: "Lang",
50729
+ content: lang,
50730
+ width: "fill_container",
50731
+ textGrowth: "fixed-width",
50732
+ textAlign: "right",
50733
+ fontFamily: token(ctx, "v3-mono"),
50734
+ fontSize: 11,
50735
+ fill: token(ctx, "v3-fg-3")
50736
+ });
50737
+ children.push({
50738
+ type: "text",
50739
+ name: "Lines",
50740
+ content: shown.join(`
50741
+ `),
50742
+ fontFamily: token(ctx, "v3-mono"),
50743
+ fontSize: 12,
50744
+ lineHeight: 1.5,
50745
+ width: "fill_container",
50746
+ textGrowth: "fixed-width",
50747
+ fill: token(ctx, "v3-code-fg")
50748
+ });
50749
+ return {
50750
+ type: "frame",
50751
+ name: "Code",
50752
+ layout: "vertical",
50753
+ gap: 6,
50754
+ width: "fill_container",
50755
+ fill: token(ctx, "v3-code-bg"),
50756
+ cornerRadius: token(ctx, "r-md"),
50757
+ padding: 12,
50758
+ clip: true,
50759
+ children
50760
+ };
50761
+ }
50762
+ function indexed(index) {
50763
+ return /^\d+$/.test(index) ? index.padStart(2, "0") : index;
50764
+ }
50765
+ var SECTION_KEYS = ["index", "title", "subtitle"];
50766
+ function planSection(options, ctx) {
50767
+ const o = optionKeys(options, SECTION_KEYS, "Kit.Section");
50768
+ const title = requiredString(o.title, "title");
50769
+ const subtitle = optionalString(o.subtitle, "subtitle");
50770
+ const index = o.index === undefined || o.index === null ? undefined : textOf(o.index);
50771
+ if (index !== undefined && index === "")
50772
+ invalid("index", "expected a non-empty string or number");
50773
+ const font = token(ctx, "v3-font");
50774
+ const heading = {
50775
+ type: "frame",
50776
+ name: "Heading",
50777
+ layout: "horizontal",
50778
+ gap: 8,
50779
+ alignItems: "center",
50780
+ width: "fill_container",
50781
+ children: [
50782
+ ...index === undefined ? [] : [{ type: "text", name: "Index", content: indexed(index), fontFamily: font, fontSize: 14, fill: token(ctx, "v3-fg-3") }],
50783
+ { type: "text", name: "Title", content: title, fontFamily: font, fontSize: 20, fontWeight: 600, fill: token(ctx, "v3-fg"), width: "fill_container", textGrowth: "fixed-width" }
50784
+ ]
50785
+ };
50786
+ const children = [heading];
50787
+ if (subtitle !== undefined)
50788
+ 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" });
50789
+ return { type: "frame", name: "Section", layout: "vertical", gap: 4, padding: [0, 0, 16, 0], width: "fill_container", children };
50790
+ }
50791
+ function planKeyValue(rows, ctx) {
50792
+ if (!Array.isArray(rows) || rows.length === 0)
50793
+ invalid("rows", "expected a non-empty array of { key, value }");
50794
+ const font = token(ctx, "v3-font");
50795
+ const parsed = rows.map((raw, i) => {
50796
+ const r = optionKeys(raw, ["key", "value"], `rows[${i}]`);
50797
+ return { key: requiredString(r.key, `rows[${i}].key`), value: requiredText(r.value, `rows[${i}].value`) };
50798
+ });
50799
+ const measured = Math.max(...parsed.map((r) => ctx.measure({ content: r.key, fontFamily: String(font), fontSize: BODY_SIZE }).width));
50800
+ const keyWidth = Math.min(KIT_LIMITS.keyWidth, Math.max(1, Math.ceil(measured)));
50801
+ return {
50802
+ type: "frame",
50803
+ name: "KeyValue",
50804
+ layout: "vertical",
50805
+ gap: 0,
50806
+ width: "fill_container",
50807
+ children: parsed.map((r) => ({
50808
+ type: "frame",
50809
+ name: "KeyValueRow",
50810
+ layout: "horizontal",
50811
+ gap: 12,
50812
+ padding: [6, 0],
50813
+ width: "fill_container",
50814
+ children: [
50815
+ { type: "text", name: "Key", content: r.key, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg-3"), width: keyWidth, textGrowth: "fixed-width" },
50816
+ { type: "text", name: "Value", content: r.value, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg"), width: "fill_container", textGrowth: "fixed-width" }
50817
+ ]
50818
+ }))
50819
+ };
50820
+ }
50821
+ var KIT_BUILDERS = {
50822
+ table: planTable,
50823
+ callout: planCallout,
50824
+ code: planCode,
50825
+ section: planSection,
50826
+ "key-value": planKeyValue
50827
+ };
50828
+ function planKitNode(kind, options, ctx) {
50829
+ const build = typeof kind === "string" && Object.hasOwn(KIT_BUILDERS, kind) ? KIT_BUILDERS[kind] : undefined;
50830
+ if (!build)
50831
+ return invalid("kind", `unknown builder ${JSON.stringify(kind)}; expected one of ${Object.keys(KIT_BUILDERS).join(", ")}`);
50832
+ return build(options, ctx);
50833
+ }
50834
+
50321
50835
  // ../../packages/canvas/document/src/execute-api.ts
50836
+ var MOVING_KEYS = ["x", "y", "width", "height", "layout", "layoutPosition", "padding", "gap", "justifyContent", "alignItems", "cornerRadius", "rotation"];
50322
50837
  var CONNECT_KEYS = new Set(["route", "fromMagnet", "toMagnet", "arrow", "label", "labelPos", "stroke", "strokeWidth", "dash", "behind", "parent", "name"]);
50838
+ function connectorMetaOf(props) {
50839
+ const meta = props?.metadata?.connector;
50840
+ if (!meta || typeof meta !== "object")
50841
+ return null;
50842
+ const m = meta;
50843
+ if (typeof m.from !== "string" || typeof m.to !== "string")
50844
+ return null;
50845
+ return {
50846
+ from: m.from,
50847
+ to: m.to,
50848
+ fromMagnet: m.fromMagnet ?? "auto",
50849
+ toMagnet: m.toMagnet ?? "auto",
50850
+ route: m.route ?? "straight",
50851
+ arrow: m.arrow ?? "end",
50852
+ labelPos: typeof m.labelPos === "number" ? m.labelPos : 0.5,
50853
+ ...Array.isArray(m.dash) ? { dash: m.dash } : {},
50854
+ ...typeof m.labelId === "string" ? { labelId: m.labelId } : {}
50855
+ };
50856
+ }
50323
50857
  var MEASURE_KEYS = new Set(["fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "width"]);
50324
- function invalid(property, reason) {
50858
+ function invalid2(property, reason) {
50325
50859
  throw new OpRejectedError({ code: "INVALID_VALUE", property, reason });
50326
50860
  }
50327
50861
  function pickOption(value, allowed, property, fallback) {
@@ -50329,30 +50863,30 @@ function pickOption(value, allowed, property, fallback) {
50329
50863
  return fallback;
50330
50864
  if (typeof value === "string" && allowed.includes(value))
50331
50865
  return value;
50332
- return invalid(property, `expected one of ${allowed.join(", ")}`);
50866
+ return invalid2(property, `expected one of ${allowed.join(", ")}`);
50333
50867
  }
50334
50868
  function numberOption(value, property, fallback, positive = false) {
50335
50869
  if (value === undefined || value === null)
50336
50870
  return fallback;
50337
50871
  if (typeof value !== "number" || !Number.isFinite(value) || positive && value <= 0)
50338
- return invalid(property, positive ? "expected a positive number" : "expected a number");
50872
+ return invalid2(property, positive ? "expected a positive number" : "expected a number");
50339
50873
  return value;
50340
50874
  }
50341
- function optionKeys(value, allowed, name) {
50875
+ function optionKeys2(value, allowed, name) {
50342
50876
  if (value === undefined || value === null)
50343
50877
  return {};
50344
50878
  if (typeof value !== "object" || Array.isArray(value))
50345
- return invalid(name, "expected an options object");
50879
+ return invalid2(name, "expected an options object");
50346
50880
  for (const key of Object.keys(value))
50347
50881
  if (!allowed.has(key))
50348
- return invalid(key, `${name} does not take ${key}`);
50882
+ return invalid2(key, `${name} does not take ${key}`);
50349
50883
  return value;
50350
50884
  }
50351
50885
  function dashOption(value) {
50352
50886
  if (value === undefined || value === null)
50353
50887
  return;
50354
50888
  if (!Array.isArray(value) || !value.every((d) => typeof d === "number" && Number.isFinite(d) && d > 0))
50355
- invalid("dash", "expected an array of positive numbers");
50889
+ invalid2("dash", "expected an array of positive numbers");
50356
50890
  return value;
50357
50891
  }
50358
50892
  var LIMITS = { ops: 5000, printBytes: 64 * 1024, screenshots: 4, vectorize: 2 };
@@ -50406,6 +50940,8 @@ class ExecuteApi {
50406
50940
  document = "document";
50407
50941
  layoutCache = new Map;
50408
50942
  defaults = {};
50943
+ connectors = new Map;
50944
+ connectorsIndexed = false;
50409
50945
  constructor(store, rec, bounds, rev, random = Math.random, measureText, kits) {
50410
50946
  this.store = store;
50411
50947
  this.rec = rec;
@@ -50667,6 +51203,8 @@ class ExecuteApi {
50667
51203
  patch.descendants = { ...row.props.descendants ?? {}, ...this.resolveDescendantKeys(row.props.ref, patch.descendants) };
50668
51204
  this.warnProps({ ...patch, ...row.props.type === "ref" ? { ref: row.props.ref } : {} }, row.props.type, row.id);
50669
51205
  this.commit({ op: "update", id: row.id, patch });
51206
+ if (MOVING_KEYS.some((k) => (k in patch)) || patch.descendants && this.store.get(row.id))
51207
+ this.finalizeConnectors();
50670
51208
  }
50671
51209
  Replace(path, nodeData) {
50672
51210
  const inst = this.splitInstancePath(path);
@@ -50704,6 +51242,7 @@ class ExecuteApi {
50704
51242
  const before = i > 0 ? this.store.get(siblings[i - 1]).ord : null;
50705
51243
  const after = i < siblings.length ? this.store.get(siblings[i]).ord : null;
50706
51244
  this.commit({ op: "move", id: row.id, parent: p, ord: between(before, after) });
51245
+ this.finalizeConnectors();
50707
51246
  }
50708
51247
  Delete(path) {
50709
51248
  if (path === "document")
@@ -50713,6 +51252,7 @@ class ExecuteApi {
50713
51252
  if (!this.store.get(path))
50714
51253
  throw new OpRejectedError({ code: "NODE_NOT_FOUND", path });
50715
51254
  this.commit({ op: "delete", id: path });
51255
+ this.finalizeConnectors();
50716
51256
  }
50717
51257
  MoveToBack(path) {
50718
51258
  this.Move(path, undefined, 0);
@@ -50953,14 +51493,14 @@ class ExecuteApi {
50953
51493
  }
50954
51494
  MeasureText(content, options) {
50955
51495
  if (typeof content !== "string")
50956
- invalid("content", "expected a string");
51496
+ invalid2("content", "expected a string");
50957
51497
  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");
51498
+ invalid2("MeasureText", "this host has no font set, so text cannot be measured");
51499
+ const o = optionKeys2(options, MEASURE_KEYS, "MeasureText");
50960
51500
  if (typeof o.fontFamily !== "string" || o.fontFamily === "")
50961
- invalid("fontFamily", "expected a font family name");
51501
+ invalid2("fontFamily", "expected a font family name");
50962
51502
  if (o.fontSize === undefined || o.fontSize === null)
50963
- invalid("fontSize", "expected a positive number");
51503
+ invalid2("fontSize", "expected a positive number");
50964
51504
  return this.measureText({
50965
51505
  content,
50966
51506
  fontFamily: o.fontFamily,
@@ -50976,59 +51516,45 @@ class ExecuteApi {
50976
51516
  }
50977
51517
  Connect(from, to, options) {
50978
51518
  if (typeof from !== "string" || typeof to !== "string")
50979
- invalid("from", "expected a node id");
51519
+ invalid2("from", "expected a node id");
50980
51520
  if (from === to)
50981
- invalid("to", "a node cannot be connected to itself");
51521
+ invalid2("to", "a node cannot be connected to itself");
50982
51522
  this.rowOf(from);
50983
51523
  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");
51524
+ const o = optionKeys2(options, CONNECT_KEYS, "Connect");
50987
51525
  const route = pickOption(o.route, ROUTES, "route", "straight");
50988
51526
  const fromMagnet = pickOption(o.fromMagnet, MAGNETS, "fromMagnet", "auto");
50989
51527
  const toMagnet = pickOption(o.toMagnet, MAGNETS, "toMagnet", "auto");
50990
51528
  const arrow = pickOption(o.arrow, ARROWS, "arrow", "end");
50991
51529
  const labelPos = numberOption(o.labelPos, "labelPos", 0.5);
50992
51530
  if (labelPos < 0 || labelPos > 1)
50993
- invalid("labelPos", "expected a number between 0 and 1");
51531
+ invalid2("labelPos", "expected a number between 0 and 1");
50994
51532
  const strokeWidth = numberOption(o.strokeWidth, "strokeWidth", 1.5, true);
50995
51533
  const stroke = o.stroke === undefined || o.stroke === null ? "#64748B" : o.stroke;
50996
51534
  if (typeof stroke !== "string")
50997
- invalid("stroke", "expected a colour string");
51535
+ invalid2("stroke", "expected a colour string");
50998
51536
  const dash = dashOption(o.dash);
50999
51537
  const behind = o.behind === undefined || o.behind === null ? true : o.behind;
51000
51538
  if (typeof behind !== "boolean")
51001
- invalid("behind", "expected a boolean");
51539
+ invalid2("behind", "expected a boolean");
51002
51540
  const name = o.name === undefined || o.name === null ? "Connector" : o.name;
51003
51541
  if (typeof name !== "string")
51004
- invalid("name", "expected a string");
51542
+ invalid2("name", "expected a string");
51005
51543
  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 });
51544
+ invalid2("label", "expected a string");
51545
+ const ends = { from: this.connectorEnd(from, "from"), to: this.connectorEnd(to, "to") };
51546
+ const geom = connectorGeometry(ends.from, ends.to, { route, fromMagnet, toMagnet, arrow, strokeWidth, labelPos, dash });
51008
51547
  const parent = o.parent === undefined || o.parent === null ? this.commonParent(from, to) : this.parentId(String(o.parent));
51009
51548
  const target = parent ?? "document";
51010
51549
  const origin = this.originOf(parent);
51011
51550
  const absolute = this.inFlow(parent);
51012
51551
  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);
51552
+ let labelId;
51027
51553
  if (typeof o.label === "string" && o.label !== "") {
51028
51554
  const size = this.MeasureText(o.label, { fontFamily: "Inter", fontSize: 12 });
51029
51555
  const width = size.width + 8;
51030
51556
  const height = size.height + 4;
51031
- this.Insert(target, {
51557
+ labelId = this.Insert(target, {
51032
51558
  id: "",
51033
51559
  type: "frame",
51034
51560
  name: `${name}-label`,
@@ -51039,8 +51565,139 @@ class ExecuteApi {
51039
51565
  children: [{ id: "", type: "text", x: 4, y: 2, content: o.label, fontFamily: "Inter", fontSize: 12, fill: "#334155" }]
51040
51566
  });
51041
51567
  }
51568
+ const id = this.Insert(target, {
51569
+ id: "",
51570
+ type: "path",
51571
+ name,
51572
+ ...place(geom.bbox),
51573
+ viewBox: [0, 0, geom.bbox.width, geom.bbox.height],
51574
+ geometry: geom.geometry,
51575
+ fill: stroke,
51576
+ stroke,
51577
+ strokeWidth,
51578
+ metadata: { connector: { from, to, fromMagnet, toMagnet, route, arrow, labelPos, ...dash ? { dash } : {}, ...labelId ? { labelId } : {} } }
51579
+ });
51580
+ this.connectors.set(id, { from, to, fromMagnet, toMagnet, route, arrow, labelPos, ...dash ? { dash } : {}, ...labelId ? { labelId } : {} });
51581
+ if (behind)
51582
+ this.Move(id, target, 0);
51583
+ this.warnConnector(id, geom);
51042
51584
  return id;
51043
51585
  }
51586
+ finalizeConnectors() {
51587
+ if (!this.mutations)
51588
+ return;
51589
+ for (const id of this.knownConnectors())
51590
+ this.redrawConnector(id);
51591
+ }
51592
+ knownConnectors() {
51593
+ if (!this.connectorsIndexed) {
51594
+ this.connectorsIndexed = true;
51595
+ const walk = (parent) => {
51596
+ for (const id of this.store.children(parent)) {
51597
+ const props = this.store.get(id)?.props;
51598
+ if (!props)
51599
+ continue;
51600
+ const meta = connectorMetaOf(props);
51601
+ if (meta && !this.connectors.has(id))
51602
+ this.connectors.set(id, meta);
51603
+ walk(id);
51604
+ }
51605
+ };
51606
+ walk(null);
51607
+ }
51608
+ return [...this.connectors.keys()];
51609
+ }
51610
+ redrawConnector(id) {
51611
+ const row = this.store.get(id);
51612
+ const meta = row ? connectorMetaOf(row.props) : null;
51613
+ if (!row || !meta) {
51614
+ this.connectors.delete(id);
51615
+ return;
51616
+ }
51617
+ const from = this.absoluteOf(meta.from);
51618
+ const to = this.absoluteOf(meta.to);
51619
+ if (!from || !to || from.width === 0 && from.height === 0 || to.width === 0 && to.height === 0) {
51620
+ 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`);
51621
+ return;
51622
+ }
51623
+ const end = (box2, path) => {
51624
+ const props = this.store.get(path).props;
51625
+ return { box: box2, shape: String(props.type), cornerRadius: typeof props.cornerRadius === "number" ? props.cornerRadius : 0 };
51626
+ };
51627
+ const geom = connectorGeometry(end(from, meta.from), end(to, meta.to), {
51628
+ route: meta.route,
51629
+ fromMagnet: meta.fromMagnet,
51630
+ toMagnet: meta.toMagnet,
51631
+ arrow: meta.arrow,
51632
+ labelPos: meta.labelPos,
51633
+ dash: meta.dash,
51634
+ strokeWidth: typeof row.props.strokeWidth === "number" ? row.props.strokeWidth : 1.5
51635
+ });
51636
+ const origin = this.originOf(row.parent);
51637
+ const box = { x: geom.bbox.x - origin.x, y: geom.bbox.y - origin.y, width: geom.bbox.width, height: geom.bbox.height };
51638
+ const viewBox = [0, 0, geom.bbox.width, geom.bbox.height];
51639
+ const patch = {};
51640
+ for (const [key, value] of Object.entries({ ...box, viewBox, geometry: geom.geometry }))
51641
+ if (JSON.stringify(row.props[key]) !== JSON.stringify(value))
51642
+ patch[key] = value;
51643
+ if (Object.keys(patch).length)
51644
+ this.commit({ op: "update", id, patch });
51645
+ if (meta.labelId) {
51646
+ const label = this.store.get(meta.labelId);
51647
+ const labelBox = this.absoluteOf(meta.labelId);
51648
+ if (label && labelBox) {
51649
+ const x = geom.labelCenter.x - labelBox.width / 2 - origin.x;
51650
+ const y = geom.labelCenter.y - labelBox.height / 2 - origin.y;
51651
+ const labelPatch = {};
51652
+ if (label.props.x !== x)
51653
+ labelPatch.x = x;
51654
+ if (label.props.y !== y)
51655
+ labelPatch.y = y;
51656
+ if (Object.keys(labelPatch).length)
51657
+ this.commit({ op: "update", id: meta.labelId, patch: labelPatch });
51658
+ }
51659
+ }
51660
+ this.warnConnector(id, geom);
51661
+ }
51662
+ warnOnce(code, nodeId, message) {
51663
+ if (this.rec.warnings.length >= 20)
51664
+ return;
51665
+ if (this.rec.warnings.some((w) => w.code === code && w.nodeId === nodeId))
51666
+ return;
51667
+ this.rec.warnings.push({ code, nodeId, message });
51668
+ }
51669
+ warnConnector(id, geom) {
51670
+ const row = this.store.get(id);
51671
+ if (!row)
51672
+ return;
51673
+ const meta = connectorMetaOf(row.props);
51674
+ const labelIds = new Set;
51675
+ for (const m of this.connectors.values())
51676
+ if (m.labelId)
51677
+ labelIds.add(m.labelId);
51678
+ let labelBox = null;
51679
+ for (const sibling of this.store.children(row.parent)) {
51680
+ const props = this.store.get(sibling)?.props;
51681
+ if (!props || sibling === id)
51682
+ continue;
51683
+ const box = this.absoluteOf(sibling);
51684
+ if (!box || box.width === 0 && box.height === 0)
51685
+ continue;
51686
+ if (sibling === meta?.labelId) {
51687
+ labelBox = box;
51688
+ continue;
51689
+ }
51690
+ if (!labelIds.has(sibling) && !this.connectors.has(sibling) && sibling !== meta?.from && sibling !== meta?.to) {
51691
+ for (let i = 1;i < geom.polyline.length; i++)
51692
+ if (segmentCrossesBox(geom.polyline[i - 1], geom.polyline[i], box)) {
51693
+ this.warnOnce("CONNECTOR_CROSSES_NODE", id, `line crosses ${String(props.name ?? sibling)}`);
51694
+ break;
51695
+ }
51696
+ }
51697
+ if (labelBox && rectsOverlap(labelBox, box))
51698
+ this.warnOnce("LABEL_OVERLAP", id, `label overlaps ${String(props.name ?? sibling)}`);
51699
+ }
51700
+ }
51044
51701
  absoluteOf(path) {
51045
51702
  if (path === null || path === "")
51046
51703
  return { x: 0, y: 0, width: 0, height: 0 };
@@ -51055,14 +51712,14 @@ class ExecuteApi {
51055
51712
  return { x: 0, y: 0 };
51056
51713
  const box = this.absoluteOf(parent);
51057
51714
  if (!box)
51058
- invalid("parent", `${parent} has no laid-out box`);
51715
+ invalid2("parent", `${parent} has no laid-out box`);
51059
51716
  return { x: box.x, y: box.y };
51060
51717
  }
51061
51718
  connectorEnd(id, property) {
51062
51719
  const row = this.rowOf(id);
51063
51720
  const box = this.absoluteOf(id);
51064
51721
  if (!box || box.width === 0 && box.height === 0)
51065
- invalid(property, `${id} has no laid-out box to attach to`);
51722
+ invalid2(property, `${id} has no laid-out box to attach to`);
51066
51723
  return { box, shape: String(row.props.type), cornerRadius: typeof row.props.cornerRadius === "number" ? row.props.cornerRadius : 0 };
51067
51724
  }
51068
51725
  commonParent(a, b) {
@@ -51109,15 +51766,26 @@ class ExecuteApi {
51109
51766
  return { x: minX, y: maxY + pad };
51110
51767
  return { x: minX, y: minY - pad - input.height };
51111
51768
  }
51769
+ KitPlan(kind, options) {
51770
+ const variables = this.store.variables();
51771
+ return planKitNode(kind, options, {
51772
+ variables: new Set(Object.keys(variables)),
51773
+ measure: (request) => {
51774
+ const family = typeof request.fontFamily === "string" && request.fontFamily.startsWith("$") ? variables[request.fontFamily.slice(1)]?.value : request.fontFamily;
51775
+ const { content, ...options2 } = { ...request, fontFamily: typeof family === "string" && family !== "" ? family : "Geist" };
51776
+ return this.MeasureText(content, options2);
51777
+ }
51778
+ });
51779
+ }
51112
51780
  ListKits() {
51113
51781
  return this.kits?.list() ?? [];
51114
51782
  }
51115
51783
  UseKit(name) {
51116
51784
  if (typeof name !== "string" || name === "")
51117
- invalid("name", "expected a kit name");
51785
+ invalid2("name", "expected a kit name");
51118
51786
  const entry = this.kits?.get(name);
51119
51787
  if (!entry)
51120
- invalid("name", `unknown kit ${JSON.stringify(name)}; available: ${this.kits?.names().join(", ") || "none"}`);
51788
+ invalid2("name", `unknown kit ${JSON.stringify(name)}; available: ${this.kits?.names().join(", ") || "none"}`);
51121
51789
  const plan = planKit(existingKitNodesIn(this.store, entry.kit.name), entry.kit);
51122
51790
  const { refs, ids } = planRefs(plan);
51123
51791
  for (const ref of refs)
@@ -51175,17 +51843,17 @@ class ExecuteApi {
51175
51843
  }
51176
51844
  Vectorize(frameId, fileId, opts) {
51177
51845
  if (typeof frameId !== "string" || frameId === "")
51178
- invalid("frameId", "expected a frame id");
51846
+ invalid2("frameId", "expected a frame id");
51179
51847
  if (typeof fileId !== "string" || fileId === "")
51180
- invalid("fileId", "expected a file id");
51181
- const options = optionKeys(opts, VECTORIZE_KEYS, "Vectorize");
51848
+ invalid2("fileId", "expected a file id");
51849
+ const options = optionKeys2(opts, VECTORIZE_KEYS, "Vectorize");
51182
51850
  const mode = options.mode === undefined || options.mode === null ? undefined : pickOption(options.mode, VECTORIZE_MODES, "mode", "auto");
51183
51851
  const maxColors = options.maxColors === undefined || options.maxColors === null ? undefined : options.maxColors;
51184
51852
  if (maxColors !== undefined && (typeof maxColors !== "number" || !Number.isInteger(maxColors) || maxColors < 1))
51185
- invalid("maxColors", "expected a positive integer");
51853
+ invalid2("maxColors", "expected a positive integer");
51186
51854
  const allowComplex = options.allowComplex === undefined || options.allowComplex === null ? undefined : options.allowComplex;
51187
51855
  if (allowComplex !== undefined && typeof allowComplex !== "boolean")
51188
- invalid("allowComplex", "expected a boolean");
51856
+ invalid2("allowComplex", "expected a boolean");
51189
51857
  if (this.rec.pendingVectorize.length >= LIMITS.vectorize)
51190
51858
  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
51859
  const requestId = this.newRequestId();
@@ -52154,7 +52822,7 @@ function startProgress(ctx, write = (text) => writeOutput({ stderr: text })) {
52154
52822
  }
52155
52823
 
52156
52824
  // src/main.ts
52157
- var version = "0.3.0-dev.2615392";
52825
+ var version = "0.3.0-dev.40e3123";
52158
52826
  var commands = commandTree(operations);
52159
52827
  var manual = [...workflows.map((w) => w.words), [API_WORD]];
52160
52828
  function route(argv) {
@@ -52408,16 +53076,16 @@ Examples:
52408
53076
  const cursor = result instanceof Page ? result.next_cursor : record(result).next_cursor ?? record(result).nextToken;
52409
53077
  if (typeof cursor === "string" && cursor)
52410
53078
  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`);
53079
+ const pageToken = pageTokenField(op), token2 = pageToken?.sdkName ?? pageToken?.name;
53080
+ const firstPage = flags.all && !(result instanceof Page) && token2 ? pageOf(result) : undefined;
53081
+ if (flags.all && !(result instanceof Page) && token2 && !firstPage)
53082
+ throw new UsageError(`--all cannot find the list in ${op.resource}.${op.method}'s response; page with --${token2.replace(/_/g, "-")} instead`);
52415
53083
  if (firstPage) {
52416
53084
  const items = [...firstPage.items];
52417
53085
  const seen = new Set;
52418
53086
  for (let next = firstPage.token;next && !seen.has(next); next = pageOf(result)?.token) {
52419
53087
  seen.add(next);
52420
- result = await owner[op.method]({ ...opts, query: { ...opts.query, [token]: next } });
53088
+ result = await owner[op.method]({ ...opts, query: { ...opts.query, [token2]: next } });
52421
53089
  items.push(...pageOf(result)?.items ?? []);
52422
53090
  }
52423
53091
  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.40e3123",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "praxis": "dist/praxis.js"