@neta-art/cohub-cli 10.29.0 → 10.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/board-gpu/page.js +3011 -133
  2. package/dist/bootstrap.js +2 -4
  3. package/dist/build.json +1 -1
  4. package/dist/chunks/FilterPipe.js +145 -269
  5. package/dist/chunks/about.js +2 -3
  6. package/dist/chunks/app-realtime.js +113 -115
  7. package/dist/chunks/app-realtime2.js +1 -2
  8. package/dist/chunks/app-ref.js +4 -5
  9. package/dist/chunks/apps.js +8 -14
  10. package/dist/chunks/auth.js +1 -2
  11. package/dist/chunks/avatar.js +2 -4
  12. package/dist/chunks/binary-pins.js +1 -2
  13. package/dist/chunks/board-export-resources.js +55 -12
  14. package/dist/chunks/board-export.js +26 -21
  15. package/dist/chunks/board-export2.js +1 -2
  16. package/dist/chunks/board-kernel.js +2672 -1623
  17. package/dist/chunks/board-kernel2.js +2 -2
  18. package/dist/chunks/board-model.js +970 -0
  19. package/dist/chunks/board-profile.js +4 -5
  20. package/dist/chunks/board-simulate.js +6 -6
  21. package/dist/chunks/board-time.js +1 -2
  22. package/dist/chunks/boards.js +547 -23
  23. package/dist/chunks/browserAll.js +18 -35
  24. package/dist/chunks/channels.js +1 -2
  25. package/dist/chunks/client.js +637 -713
  26. package/dist/chunks/command-input.js +1 -2
  27. package/dist/chunks/commander.js +16 -22
  28. package/dist/chunks/cron-jobs.js +2 -3
  29. package/dist/chunks/daemon.js +18 -4
  30. package/dist/chunks/daemon2.js +1 -2
  31. package/dist/chunks/desktop.js +2 -3
  32. package/dist/chunks/endpoint-options.js +1 -2
  33. package/dist/chunks/env-proxy.js +4 -5
  34. package/dist/chunks/environment.js +2 -4
  35. package/dist/chunks/feedback.js +3 -4
  36. package/dist/chunks/generations.js +3 -4
  37. package/dist/chunks/host.js +1 -2
  38. package/dist/chunks/http-put.js +1 -2
  39. package/dist/chunks/id.js +77 -928
  40. package/dist/chunks/init.js +7 -12
  41. package/dist/chunks/install.js +142 -138
  42. package/dist/chunks/launch.js +4 -6
  43. package/dist/chunks/lexer.js +226 -66
  44. package/dist/chunks/local-media.js +1 -2
  45. package/dist/chunks/me.js +1 -2
  46. package/dist/chunks/media.js +1 -2
  47. package/dist/chunks/{themes.js → model-clips.js} +395 -43
  48. package/dist/chunks/models.js +3 -5
  49. package/dist/chunks/operands.js +1 -2
  50. package/dist/chunks/package-paths.js +1 -2
  51. package/dist/chunks/policy.js +1 -2
  52. package/dist/chunks/preferences.js +1 -2
  53. package/dist/chunks/profile.js +2 -3
  54. package/dist/chunks/prompts.js +1 -2
  55. package/dist/chunks/public.js +1 -2
  56. package/dist/chunks/public2.js +3 -4
  57. package/dist/chunks/references.js +3 -3
  58. package/dist/chunks/referrals.js +1 -2
  59. package/dist/chunks/rolldown-runtime.js +2 -3
  60. package/dist/chunks/rooms-connect.js +1 -2
  61. package/dist/chunks/rooms-connect2.js +1 -2
  62. package/dist/chunks/rooms-rtc.js +4 -6
  63. package/dist/chunks/rooms.js +2 -3
  64. package/dist/chunks/run.js +2 -3
  65. package/dist/chunks/runtime.js +6 -12
  66. package/dist/chunks/runtime2.js +2 -3
  67. package/dist/chunks/runtimes.js +1 -2
  68. package/dist/chunks/safe-remote-image.js +1 -2
  69. package/dist/chunks/schemas.js +58 -43
  70. package/dist/chunks/search.js +3 -3
  71. package/dist/chunks/self-update.js +4 -5
  72. package/dist/chunks/serve.js +11 -25
  73. package/dist/chunks/session-status.js +1 -2
  74. package/dist/chunks/skills.js +1 -2
  75. package/dist/chunks/spaces.js +26 -45
  76. package/dist/chunks/src.js +5 -9
  77. package/dist/chunks/supervisor.js +16 -28
  78. package/dist/chunks/supervisor2.js +1 -2
  79. package/dist/chunks/tasks.js +1 -2
  80. package/dist/chunks/user-lists.js +1 -2
  81. package/dist/chunks/version.js +1 -2
  82. package/dist/chunks/version2.js +1 -2
  83. package/dist/chunks/version3.js +3 -4
  84. package/dist/chunks/web.js +1 -2
  85. package/dist/runtime/native/pi-extension.js +1 -2
  86. package/dist/runtime/worker.js +2 -3
  87. package/package.json +11 -10
@@ -1,5 +1,6 @@
1
- import { A as invertMatrix, C as clampBoardFontSize, I as scaleVector, M as layoutBoardText, N as matrixRotation, T as drawPointsBounds, W as BOARD_CAMERA_TARGET, Z as BOARD_SHADOW_DEFAULTS, _ as IDENTITY_MATRIX, b as arrowBindings, et as BoardColorSchema, g as resolveBoardProperty, ht as BOARD_CAMERA_VIEWPORT, nt as BoardIdSchema, r as sameJson, t as createBoardEntityId, u as applyBoardPatchToDocument, w as createBoardLayout, y as applyMatrix } from "./id.js";
2
- //#region ../sdk/src/board/model/geometry.ts
1
+ import { A as parseBoardMediaSource, I as BOARD_CAMERA_VIEWPORT, c as BOARD_SHADOW_DEFAULTS, d as BoardColorSchema, m as BoardIdSchema, t as BOARD_CAMERA_TARGET } from "./board-model.js";
2
+ import { A as invertMatrix, C as clampBoardFontSize, L as scaleVector, M as itemBindings, N as layoutBoardText, P as matrixRotation, T as drawPointsBounds, _ as IDENTITY_MATRIX, g as resolveBoardProperty, r as sameJson, s as modelFormatForPath, t as createBoardEntityId, u as applyBoardPatchToDocument, w as createBoardLayout, y as applyMatrix } from "./id.js";
3
+ // ../sdk/src/board/model/geometry.ts
3
4
  function screenPoint(x, y) {
4
5
  return {
5
6
  x,
@@ -32,10 +33,14 @@ function normalizeViewport(viewport, fallback = DEFAULT_BOARD_VIEWPORT) {
32
33
  const fallbackX = Number.isFinite(fallback.x) ? fallback.x : DEFAULT_BOARD_VIEWPORT.x;
33
34
  const fallbackY = Number.isFinite(fallback.y) ? fallback.y : DEFAULT_BOARD_VIEWPORT.y;
34
35
  const fallbackZoom = Number.isFinite(fallback.zoom) ? clampZoom(fallback.zoom) : DEFAULT_BOARD_VIEWPORT.zoom;
36
+ const pitch = Number.isFinite(viewport.pitch) ? clamp(viewport.pitch, 0, 60) : 0;
37
+ const bearing = Number.isFinite(viewport.bearing) ? viewport.bearing : 0;
35
38
  return {
36
39
  x: Number.isFinite(viewport.x) ? viewport.x : fallbackX,
37
40
  y: Number.isFinite(viewport.y) ? viewport.y : fallbackY,
38
- zoom: Number.isFinite(viewport.zoom) ? clampZoom(viewport.zoom) : fallbackZoom
41
+ zoom: Number.isFinite(viewport.zoom) ? clampZoom(viewport.zoom) : fallbackZoom,
42
+ ...pitch ? { pitch } : {},
43
+ ...bearing ? { bearing } : {}
39
44
  };
40
45
  }
41
46
  function clamp(value, min, max) {
@@ -378,29 +383,14 @@ function normalizeRotation(degrees) {
378
383
  function pointToWorld(point, viewport) {
379
384
  return worldPoint((point.x - viewport.x) / viewport.zoom, (point.y - viewport.y) / viewport.zoom);
380
385
  }
381
- function zoomAround(viewport, anchor, nextZoom, minZoom) {
382
- const current = normalizeViewport(viewport);
383
- const zoom = Number.isFinite(nextZoom) ? clampZoom(nextZoom, minZoom) : current.zoom;
384
- const world = pointToWorld(anchor, current);
385
- return {
386
- x: anchor.x - world.x * zoom,
387
- y: anchor.y - world.y * zoom,
388
- zoom
389
- };
390
- }
391
- function panBy(viewport, dx, dy) {
392
- return {
393
- ...viewport,
394
- x: viewport.x + dx,
395
- y: viewport.y + dy
396
- };
397
- }
398
386
  function stateForCamera(camera, surface) {
399
- const { x, y, zoom } = normalizeViewport(camera);
387
+ const { x, y, zoom, pitch, bearing } = normalizeViewport(camera);
400
388
  return {
401
389
  centerX: (surface.width / 2 - x) / zoom,
402
390
  centerY: (surface.height / 2 - y) / zoom,
403
- zoom
391
+ zoom,
392
+ ...pitch ? { pitch } : {},
393
+ ...bearing ? { bearing } : {}
404
394
  };
405
395
  }
406
396
  function cameraForState(state, surface) {
@@ -408,7 +398,9 @@ function cameraForState(state, surface) {
408
398
  return normalizeViewport({
409
399
  x: surface.width / 2 - state.centerX * zoom,
410
400
  y: surface.height / 2 - state.centerY * zoom,
411
- zoom
401
+ zoom,
402
+ pitch: state.pitch,
403
+ bearing: state.bearing
412
404
  });
413
405
  }
414
406
  function cameraForRect(content, surface, options = {}) {
@@ -446,8 +438,7 @@ function visibleWorldRect(viewport, surfaceWidth, surfaceHeight) {
446
438
  height: height / zoom
447
439
  };
448
440
  }
449
- //#endregion
450
- //#region ../sdk/src/board/model/script-example.ts
441
+ // ../sdk/src/board/model/script-example.ts
451
442
  const BOARD_SCRIPT_DRAWING_EXAMPLE = `export const animated = true;
452
443
 
453
444
  export const parameters = {
@@ -747,8 +738,204 @@ export function draw(ctx, { state }) {
747
738
  }
748
739
  }
749
740
  `;
750
- //#endregion
751
- //#region ../sdk/src/board/model/animation.ts
741
+ const BOARD_SCRIPT_HANKY_EXAMPLE = `// A handkerchief from a Northeastern song-and-dance duet: tap it three times, or type
742
+ // "toss" in play, and it flies up spinning for every viewer, then drops back to rest.
743
+ // It draws the cloth and lifts itself, or the frame named by script.targets.lift, whose
744
+ // children then travel in the same picture.
745
+ const DURATION = 3200;
746
+ const ease = (t) => 1 - (1 - t) ** 3;
747
+ const smooth = (t) => t * t * (3 - 2 * t);
748
+ const clamp = (t) => Math.min(Math.max(t, 0), 1);
749
+
750
+ export default function (ctx) {
751
+ let taps = 0;
752
+ let idle = 0;
753
+ let watch = null;
754
+ let typed = "";
755
+ let stop = null;
756
+ ctx.hitRegions({ hanky: { target: "self", label: "Toss the handkerchief", cursor: "pointer", over: true } });
757
+
758
+ const toss = () => {
759
+ spin();
760
+ ctx.broadcast("toss");
761
+ };
762
+ // Three taps, each within 600 ms of the last, timed on the script clock.
763
+ const forget = () => {
764
+ taps = 0;
765
+ watch?.();
766
+ watch = null;
767
+ };
768
+ ctx.on("click", () => {
769
+ taps += 1;
770
+ idle = 0;
771
+ if (taps >= 3) {
772
+ forget();
773
+ return toss();
774
+ }
775
+ watch ??= ctx.onFrame(({ dt }) => {
776
+ idle += dt;
777
+ if (idle > 600) forget();
778
+ });
779
+ });
780
+ ctx.on("keydown", ({ key }) => {
781
+ typed = (typed + key).slice(-4).toLowerCase();
782
+ if (typed === "toss") toss();
783
+ });
784
+ // Our own broadcast comes back with peer: null; we already spin.
785
+ ctx.on("toss", ({ peer }) => {
786
+ if (peer) spin();
787
+ });
788
+
789
+ const target = ctx.targets.lift ?? ctx.self.id;
790
+
791
+ function spin() {
792
+ if (stop) return;
793
+ const box = ctx.get(target)?.size ?? ctx.self.base.size;
794
+ const size = Math.max(box.width, box.height);
795
+ const gentle = ctx.env.reducedMotion;
796
+ let t = 0;
797
+ stop = ctx.onFrame(({ dt }) => {
798
+ t += dt;
799
+ const p = clamp(t / DURATION);
800
+ const windup = smooth(clamp(p / 0.12));
801
+ const q = clamp((p - 0.1) / 0.7);
802
+ const air = 4 * q * (1 - q);
803
+ const land = clamp((p - 0.8) / 0.2);
804
+ const settle = land ? Math.exp(-land * 5) * Math.sin(land * 18) : 0;
805
+ const hold = 1 - smooth(land);
806
+ ctx.present(target, {
807
+ depth: {
808
+ lift: gentle ? size * 0.1 * air : size * (0.06 * windup * hold + 0.55 * air) + size * 0.03 * settle,
809
+ tilt: gentle
810
+ ? { x: 0, y: 0 }
811
+ : { x: (30 * windup + 10 * Math.sin(t / 180) * air) * hold + 6 * settle, y: 14 * Math.sin(t / 260) * air },
812
+ spin: gentle ? 0 : 1440 * ease(p),
813
+ bend: { kind: "cloth", amount: (0.25 * windup + 0.35 * air) * hold + 0.12 * Math.abs(settle), phase: t / 70 },
814
+ shade: 0.7,
815
+ },
816
+ });
817
+ if (p < 1) return;
818
+ ctx.present(target, null);
819
+ stop();
820
+ stop = null;
821
+ if (ctx.capabilities.has("haptics")) ctx.capabilities.call("haptics", { kind: "confirm" });
822
+ });
823
+ }
824
+ }
825
+
826
+ // A red octagon of peonies and leaves, edged with gold stitching.
827
+ export function draw(g, { width, height }) {
828
+ let seed = 7;
829
+ const rand = () => (seed = (seed * 16807) % 2147483647) / 2147483647;
830
+ const cut = Math.min(width, height) * 0.2;
831
+ const octagon = (inset) => {
832
+ const c = cut + inset * 0.41;
833
+ g.beginPath();
834
+ g.moveTo(c, inset);
835
+ g.lineTo(width - c, inset);
836
+ g.lineTo(width - inset, c);
837
+ g.lineTo(width - inset, height - c);
838
+ g.lineTo(width - c, height - inset);
839
+ g.lineTo(c, height - inset);
840
+ g.lineTo(inset, height - c);
841
+ g.lineTo(inset, c);
842
+ g.closePath();
843
+ };
844
+ octagon(0);
845
+ g.save();
846
+ g.clip();
847
+ g.fillStyle = "#b3122e";
848
+ g.fillRect(0, 0, width, height);
849
+ const leaf = (x, y, r, a) => {
850
+ g.save();
851
+ g.translate(x, y);
852
+ g.rotate(a);
853
+ g.fillStyle = "#2f8f46";
854
+ g.beginPath();
855
+ g.ellipse(r * 0.9, 0, r * 0.75, r * 0.3, 0, 0, Math.PI * 2);
856
+ g.fill();
857
+ g.restore();
858
+ };
859
+ const peony = (x, y, r, colors) => {
860
+ for (let i = 0; i < 4; i++) leaf(x, y, r, rand() * Math.PI * 2);
861
+ for (const [k, color] of [[1, colors[0]], [0.78, colors[1]], [0.55, colors[0]], [0.34, colors[2]]]) {
862
+ g.fillStyle = color;
863
+ for (let i = 0; i < 9; i++) {
864
+ const a = (i / 9) * Math.PI * 2 + k * 3;
865
+ g.beginPath();
866
+ g.ellipse(x + Math.cos(a) * r * k * 0.45, y + Math.sin(a) * r * k * 0.45, r * k * 0.55, r * k * 0.36, a, 0, Math.PI * 2);
867
+ g.fill();
868
+ }
869
+ }
870
+ g.fillStyle = "#ffd23f";
871
+ g.beginPath();
872
+ g.arc(x, y, r * 0.14, 0, Math.PI * 2);
873
+ g.fill();
874
+ };
875
+ const palettes = [["#f2558c", "#ffc2d6", "#ffffff"], ["#ffffff", "#ffd6e3", "#f2558c"], ["#f7a531", "#ffe2a8", "#ffffff"], ["#5aa6ff", "#cfe4ff", "#ffffff"]];
876
+ const step = Math.max(width, height) / 3.2;
877
+ for (let y = step * 0.4; y < height + step * 0.5; y += step * 0.86)
878
+ for (let x = (Math.round(y / step) % 2) * step * 0.5 + step * 0.3; x < width + step * 0.5; x += step)
879
+ peony(x + (rand() - 0.5) * step * 0.2, y + (rand() - 0.5) * step * 0.2, step * (0.26 + rand() * 0.08), palettes[Math.floor(rand() * palettes.length)]);
880
+ g.restore();
881
+ g.lineWidth = 12;
882
+ g.strokeStyle = "#ffd23f";
883
+ g.setLineDash([3, 7]);
884
+ octagon(6);
885
+ g.stroke();
886
+ }
887
+ `;
888
+ const BOARD_SCRIPT_ARENA_EXAMPLE = `// A fox to steer with WASD, the arrow keys or a gamepad; hold Shift to run. In Play a low camera
889
+ // follows it, its clips crossfade as it stops, walks and runs, and the glow riding its head goes along.
890
+ export const parameters = {
891
+ speed: { type: "number", label: "Run speed", default: 420, min: 60, max: 1200 },
892
+ pitch: { type: "number", label: "Camera pitch", default: 45, min: 0, max: 60 },
893
+ idle: { type: "string", label: "Idle clip", default: "Survey" },
894
+ walk: { type: "string", label: "Walk clip", default: "Walk" },
895
+ run: { type: "string", label: "Run clip", default: "Run" },
896
+ };
897
+
898
+ const KEYS = { left: ["a", "arrowleft"], right: ["d", "arrowright"], up: ["w", "arrowup"], down: ["s", "arrowdown"] };
899
+
900
+ export default function (ctx) {
901
+ const fox = ctx.targets.fox;
902
+ const held = new Set();
903
+ const pressed = (name) => KEYS[name].some((key) => held.has(key));
904
+ ctx.on("keydown", ({ key }) => held.add(key.toLowerCase()));
905
+ ctx.on("keyup", ({ key }) => held.delete(key.toLowerCase()));
906
+ ctx.on("browser:gamepads", ({ data }) => { ctx.state.pad = data.pads[0] ?? null; });
907
+
908
+ ctx.onFrame(({ dt }) => {
909
+ const base = ctx.get(fox);
910
+ if (!base) return;
911
+ const pad = ctx.state.pad;
912
+ const dead = (value) => (Math.abs(value ?? 0) > 0.15 ? value : 0);
913
+ const x = (pressed("right") ? 1 : 0) - (pressed("left") ? 1 : 0) + dead(pad?.axes[0]);
914
+ const y = (pressed("down") ? 1 : 0) - (pressed("up") ? 1 : 0) + dead(pad?.axes[1]);
915
+ const push = Math.min(1, Math.hypot(x, y));
916
+ const running = held.has("shift") || Boolean(pad?.buttons[0]?.pressed);
917
+ const speed = push * ctx.params.speed * (running ? 1 : 0.4);
918
+ const at = (ctx.state.at ??= { ...base.position });
919
+ if (push > 0) {
920
+ at.x += (x / Math.hypot(x, y)) * speed * (dt / 1000);
921
+ at.y += (y / Math.hypot(x, y)) * speed * (dt / 1000);
922
+ // The view's yaw turns the fox about its own axis: 0 faces the camera, -90 faces right.
923
+ const goal = (Math.atan2(-x, y) * 180) / Math.PI;
924
+ const turn = ((goal - (ctx.state.yaw ?? 0) + 540) % 360) - 180;
925
+ ctx.state.yaw = (ctx.state.yaw ?? 0) + turn * Math.min(1, dt / 90);
926
+ }
927
+ const clip = speed === 0 ? ctx.params.idle : running ? ctx.params.run : ctx.params.walk;
928
+ const view = base.props.model?.view ?? { yaw: 0, pitch: 30, zoom: 1 };
929
+ const yaw = ctx.state.yaw ?? view.yaw;
930
+ const shown = \`\${at.x},\${at.y},\${clip},\${yaw},\${ctx.params.pitch}\`;
931
+ if (shown === ctx.state.shown) return;
932
+ ctx.state.shown = shown;
933
+ ctx.present(fox, { position: at, props: { model: { animation: clip, view: { ...view, yaw } } } });
934
+ ctx.present("camera", { center: { x: at.x + base.size.width / 2, y: at.y + base.size.height / 2 }, zoom: 1.4, pitch: ctx.params.pitch });
935
+ });
936
+ }
937
+ `;
938
+ // ../sdk/src/board/model/animation.ts
752
939
  const linear = (x) => x;
753
940
  function cubicBezier(x1, y1, x2, y2) {
754
941
  const cx = 3 * x1;
@@ -1237,8 +1424,7 @@ function applyBoardEvaluation(document, evaluation) {
1237
1424
  items
1238
1425
  };
1239
1426
  }
1240
- //#endregion
1241
- //#region ../sdk/src/board/model/scene.ts
1427
+ // ../sdk/src/board/model/scene.ts
1242
1428
  const EPSILON = 1e-6;
1243
1429
  function stripScene(item) {
1244
1430
  if (!("frame" in item) && !("id" in item)) return item;
@@ -1276,7 +1462,7 @@ function buildBoardScene(document, previous) {
1276
1462
  const list = children.get(parent) ?? [];
1277
1463
  list.push(id);
1278
1464
  children.set(parent, list);
1279
- for (const bound of arrowBindings(item)) binders.set(bound, [...binders.get(bound) ?? [], id]);
1465
+ for (const bound of itemBindings(item)) binders.set(bound, [...binders.get(bound) ?? [], id]);
1280
1466
  }
1281
1467
  const layout = createBoardLayout((id) => items[id], (id) => [...children.get(id) ?? [], ...binders.get(id) ?? []]);
1282
1468
  const stable = /* @__PURE__ */ new Map();
@@ -1288,7 +1474,7 @@ function buildBoardScene(document, previous) {
1288
1474
  let result = Boolean(item && before && stripSceneSource(before) === item) && depth < 64;
1289
1475
  if (result && item?.parent && items[item.parent]) result = isStable(item.parent, depth + 1);
1290
1476
  if (result && item) {
1291
- for (const bound of arrowBindings(item)) if (items[bound] && !isStable(bound, depth + 1)) result = false;
1477
+ for (const bound of itemBindings(item)) if (items[bound] && !isStable(bound, depth + 1)) result = false;
1292
1478
  }
1293
1479
  stable.set(id, result);
1294
1480
  return result;
@@ -1536,8 +1722,7 @@ function normalizeDegrees(value) {
1536
1722
  const normalized = (value % 360 + 540) % 360 - 180;
1537
1723
  return Math.abs(normalized) < EPSILON ? 0 : Number(normalized.toFixed(6));
1538
1724
  }
1539
- //#endregion
1540
- //#region ../sdk/src/board/model/sampling.ts
1725
+ // ../sdk/src/board/model/sampling.ts
1541
1726
  function createBoardAnimationSampler(document, animation, options = {}) {
1542
1727
  const selected = animation ? document.animations[animation] : void 0;
1543
1728
  if (animation && !selected) throw new Error(`Animation ${animation} does not exist.`);
@@ -1580,7 +1765,7 @@ function createBoardAnimationSampler(document, animation, options = {}) {
1580
1765
  if (!item) continue;
1581
1766
  items[next] = item;
1582
1767
  if (item.parent) pending.push(item.parent);
1583
- pending.push(...arrowBindings(item));
1768
+ pending.push(...itemBindings(item));
1584
1769
  }
1585
1770
  const frame = buildBoardScene({
1586
1771
  ...sampled,
@@ -1641,10 +1826,13 @@ function resolveBoardAnimationCamera(override, bounds, surface, time, base = {
1641
1826
  x: camera.x + Math.sin(time / 1e3 * 91.3) * override.shake,
1642
1827
  y: camera.y + Math.cos(time / 1e3 * 77.9) * override.shake
1643
1828
  };
1829
+ const { pitch, bearing } = override;
1644
1830
  return {
1645
1831
  x: camera.x * scale + left,
1646
1832
  y: camera.y * scale + top,
1647
- zoom: camera.zoom * scale
1833
+ zoom: camera.zoom * scale,
1834
+ ...pitch ? { pitch: Math.min(60, Math.max(0, pitch)) } : {},
1835
+ ...bearing ? { bearing } : {}
1648
1836
  };
1649
1837
  }
1650
1838
  const VISIBLE = "visible";
@@ -2125,8 +2313,7 @@ function boardInsertTime(document, animation, at, length) {
2125
2313
  at: marker.at + gap
2126
2314
  } : marker), time < animation.duration ? animation.duration + gap : animation.duration);
2127
2315
  }
2128
- //#endregion
2129
- //#region ../sdk/src/board/model/authoring.ts
2316
+ // ../sdk/src/board/model/authoring.ts
2130
2317
  function validateChapterComposition(document, chapters) {
2131
2318
  const uses = /* @__PURE__ */ new Map();
2132
2319
  for (const [index, chapter] of chapters.entries()) for (const track of Object.values(document.animations[chapter.animation]?.tracks ?? {})) {
@@ -2339,8 +2526,98 @@ function boardPathTrack(target, points, options) {
2339
2526
  })
2340
2527
  };
2341
2528
  }
2342
- //#endregion
2343
- //#region ../sdk/src/board/model/frames.ts
2529
+ // ../sdk/src/board/model/media.ts
2530
+ const IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
2531
+ "png",
2532
+ "jpg",
2533
+ "jpeg",
2534
+ "gif",
2535
+ "webp",
2536
+ "avif",
2537
+ "svg"
2538
+ ]);
2539
+ const VIDEO_EXTENSIONS = /* @__PURE__ */ new Set([
2540
+ "mp4",
2541
+ "webm",
2542
+ "mov",
2543
+ "m4v"
2544
+ ]);
2545
+ const AUDIO_EXTENSIONS = /* @__PURE__ */ new Set([
2546
+ "mp3",
2547
+ "wav",
2548
+ "ogg",
2549
+ "m4a",
2550
+ "aac",
2551
+ "flac",
2552
+ "opus"
2553
+ ]);
2554
+ const TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
2555
+ "txt",
2556
+ "md",
2557
+ "json",
2558
+ "yaml",
2559
+ "yml",
2560
+ "csv",
2561
+ "ts",
2562
+ "tsx",
2563
+ "js",
2564
+ "jsx",
2565
+ "css",
2566
+ "html",
2567
+ "xml",
2568
+ "py",
2569
+ "sh"
2570
+ ]);
2571
+ function getMediaExtension(value) {
2572
+ const clean = value.split(/[?#]/, 1)[0] ?? value;
2573
+ const name = clean.split("/").pop() ?? clean;
2574
+ const index = name.lastIndexOf(".");
2575
+ return index >= 0 ? name.slice(index + 1).toLowerCase() : "";
2576
+ }
2577
+ function inferBoardMediaKind(value, mimeType) {
2578
+ if (mimeType?.startsWith("image/")) return "image";
2579
+ if (mimeType?.startsWith("video/")) return "video";
2580
+ if (mimeType?.startsWith("audio/")) return "audio";
2581
+ if (mimeType?.startsWith("text/") || mimeType === "application/json") return "text";
2582
+ const extension = getMediaExtension(value);
2583
+ if (IMAGE_EXTENSIONS.has(extension)) return "image";
2584
+ if (VIDEO_EXTENSIONS.has(extension)) return "video";
2585
+ if (AUDIO_EXTENSIONS.has(extension)) return "audio";
2586
+ if (TEXT_EXTENSIONS.has(extension)) return "text";
2587
+ return "file";
2588
+ }
2589
+ function getMediaResourceTitle(value) {
2590
+ if (!/^[a-z][a-z\d+.-]*:/i.test(value)) return value.split("/").filter(Boolean).pop() || value;
2591
+ try {
2592
+ const url = new URL(value);
2593
+ const title = url.pathname.split("/").filter(Boolean).pop() || url.hostname;
2594
+ try {
2595
+ return decodeURIComponent(title);
2596
+ } catch {
2597
+ return title;
2598
+ }
2599
+ } catch {
2600
+ return value.split("/").filter(Boolean).pop() || value;
2601
+ }
2602
+ }
2603
+ function boardModelFormat(src, mimeType) {
2604
+ const source = parseBoardMediaSource(src);
2605
+ if (!source) return null;
2606
+ const path = source.kind === "url" ? source.value.split(/[?#]/, 1)[0] ?? "" : source.value;
2607
+ return modelFormatForPath(path, mimeType);
2608
+ }
2609
+ function isBoardModelItem(item) {
2610
+ return item?.type === "file" && boardModelFormat(item.props.src, item.props.snapshot?.mimeType) !== null;
2611
+ }
2612
+ function boardModelViewKey(view) {
2613
+ return view ? [
2614
+ view.yaw,
2615
+ view.pitch,
2616
+ view.zoom,
2617
+ ...view.target ?? []
2618
+ ].join(",") : "";
2619
+ }
2620
+ // ../sdk/src/board/model/frames.ts
2344
2621
  const SAME_ROW = .5;
2345
2622
  const CROSS_WEIGHT = 2;
2346
2623
  const CENTER_WEIGHT = .1;
@@ -2433,8 +2710,7 @@ function boardRegionStep(regions, from, step) {
2433
2710
  default: return boardRegionNeighbor(regions, from, step) ?? (step === "right" ? boardRegionStep(regions, from, "next") : step === "left" ? boardRegionStep(regions, from, "previous") : null);
2434
2711
  }
2435
2712
  }
2436
- //#endregion
2437
- //#region ../sdk/src/board/model/themes.ts
2713
+ // ../sdk/src/board/model/themes.ts
2438
2714
  const BOARD_THEME_IDS = [
2439
2715
  "dark",
2440
2716
  "light",
@@ -2991,5 +3267,81 @@ const BOARD_THEME_DATA = {
2991
3267
  } }
2992
3268
  }
2993
3269
  };
2994
- //#endregion
2995
- export { panBy as $, boardAnimatesScriptParams as A, boardZoomFloor as B, createBoardAnimationSampler as C, refreshBoardScene as D, placeItem as E, BOARD_SCRIPT_RAIN_EXAMPLE as F, frameContainsPoint as G, cameraForState as H, BOARD_SCRIPT_SENSES_EXAMPLE as I, frameHandlePosition as J, frameCornerRotationHandleAt as K, BOARD_SCRIPT_SPARKS_EXAMPLE as L, evaluateBoardAnimations as M, withBoardScripts as N, sceneItemToItem as O, BOARD_SCRIPT_DRAWING_EXAMPLE as P, normalizeViewport as Q, BOARD_SCRIPT_TILT_EXAMPLE as R, boardCameraScale as S, buildBoardScene as T, degToRad as U, cameraForRect as V, effectBounds as W, itemBounds as X, frameRect as Y, normalizeRotation as Z, boardSplitTarget as _, boardNavigableFrames as a, rotateFrames as at, findBoardKeyTrack as b, boardPathTrack as c, scaleFrames as ct, boardSequencePatch as d, stateForCamera as dt, pointToWorld as et, boardInsertTime as f, unionRects as ft, boardShiftTargets as g, boardRemoveTime as h, zoomAround as ht, boardFrameRegions as i, resizeFrame as it, compileBoardAnimations as j, BOARD_SCRIPT_HISTORY_MS as k, boardPlacePatch as l, screenPoint as lt, boardRemoveTarget as m, worldPoint as mt, BOARD_THEME_IDS as n, rectContainsPoint as nt, boardReadingOrder as o, rotatePointAround as ot, boardPlaceTarget as p, visibleWorldRect as pt, frameEdgeHandleAt as q, boardFrameRegion as r, rectsIntersect as rt, boardRegionStep as s, rotationHandlePosition as st, BOARD_THEME_DATA as t, rectCenter as tt, boardSequence as u, selectionBounds as ut, boardTargetSpan as v, resolveBoardAnimationCamera as w, newBoardTrackId as x, boardTrimTarget as y, CORNER_RESIZE_HANDLES as z };
3270
+ // ../sdk/src/board/model/model-clips.ts
3271
+ function boardModelPlayback(item, reducedMotion) {
3272
+ if (item.type !== "file" || !isBoardModelItem(item)) return null;
3273
+ const model = item.props.model;
3274
+ const time = model?.time ?? null;
3275
+ return {
3276
+ clip: model?.animation ?? null,
3277
+ time,
3278
+ loop: model?.loop !== false,
3279
+ fade: model?.fade ?? 250,
3280
+ running: time === null && item.autoplay === true && !reducedMotion
3281
+ };
3282
+ }
3283
+ function boardModelNodes(names) {
3284
+ const nodes = /* @__PURE__ */ new Set();
3285
+ for (const name of names) {
3286
+ if (nodes.size >= 256) break;
3287
+ if (typeof name === "string" && name && name.length <= 240) nodes.add(name);
3288
+ }
3289
+ return [...nodes];
3290
+ }
3291
+ function readBoardModelFacts(bytes) {
3292
+ const json = gltfJson(bytes);
3293
+ if (!json) return null;
3294
+ const accessors = Array.isArray(json.accessors) ? json.accessors : [];
3295
+ const animations = Array.isArray(json.animations) ? json.animations : [];
3296
+ const nodes = boardModelNodes((Array.isArray(json.nodes) ? json.nodes : []).map((node) => node?.name));
3297
+ return {
3298
+ clips: animations.slice(0, 64).map((animation, index) => {
3299
+ let seconds = 0;
3300
+ for (const sampler of Array.isArray(animation?.samplers) ? animation.samplers : []) {
3301
+ const max = typeof sampler?.input === "number" ? accessors[sampler.input]?.max?.[0] : void 0;
3302
+ if (typeof max === "number" && Number.isFinite(max)) seconds = Math.max(seconds, max);
3303
+ }
3304
+ return {
3305
+ name: typeof animation?.name === "string" && animation.name ? animation.name.slice(0, 240) : `anim_${index}`,
3306
+ durationMs: Math.round(seconds * 1e3)
3307
+ };
3308
+ }),
3309
+ nodes
3310
+ };
3311
+ }
3312
+ function withBoardModelFacts(snapshot, facts) {
3313
+ const { clips: _clips, nodes: _nodes, ...rest } = snapshot ?? {};
3314
+ const next = {
3315
+ ...rest,
3316
+ ...facts.clips.length ? { clips: facts.clips } : {},
3317
+ ...facts.nodes.length ? { nodes: facts.nodes } : {}
3318
+ };
3319
+ return sameBoardModelClips(snapshot?.clips, next.clips) && sameNodes(snapshot?.nodes, next.nodes) ? null : next;
3320
+ }
3321
+ function sameNodes(a, b) {
3322
+ if (!a || !b) return a === b;
3323
+ return a.length === b.length && a.every((name, index) => name === b[index]);
3324
+ }
3325
+ const GLB_MAGIC = 1179937895;
3326
+ const JSON_CHUNK = 1313821514;
3327
+ function boardModelJsonLength(head) {
3328
+ if (head.byteLength < 20) return null;
3329
+ const view = new DataView(head.buffer, head.byteOffset, head.byteLength);
3330
+ if (view.getUint32(0, true) !== GLB_MAGIC) return null;
3331
+ return view.getUint32(16, true) === JSON_CHUNK ? 20 + view.getUint32(12, true) : null;
3332
+ }
3333
+ function gltfJson(bytes) {
3334
+ const glb = boardModelJsonLength(bytes);
3335
+ const text = new TextDecoder().decode(glb === null ? bytes : bytes.subarray(20, glb));
3336
+ try {
3337
+ const json = JSON.parse(text);
3338
+ return json && typeof json === "object" && "asset" in json ? json : null;
3339
+ } catch {
3340
+ return null;
3341
+ }
3342
+ }
3343
+ function sameBoardModelClips(a, b) {
3344
+ if (!a || !b) return a === b;
3345
+ return a.length === b.length && a.every((clip, index) => clip.name === b[index]?.name && clip.durationMs === b[index]?.durationMs);
3346
+ }
3347
+ export { cameraForState as $, newBoardTrackId as A, compileBoardAnimations as B, boardRemoveTarget as C, unionRects as Ct, boardTargetSpan as D, boardSplitTarget as E, placeItem as F, BOARD_SCRIPT_HANKY_EXAMPLE as G, withBoardScripts as H, refreshBoardScene as I, BOARD_SCRIPT_SPARKS_EXAMPLE as J, BOARD_SCRIPT_RAIN_EXAMPLE as K, sceneItemToItem as L, createBoardAnimationSampler as M, resolveBoardAnimationCamera as N, boardTrimTarget as O, buildBoardScene as P, cameraForRect as Q, BOARD_SCRIPT_HISTORY_MS as R, boardPlaceTarget as S, stateForCamera as St, boardShiftTargets as T, worldPoint as Tt, BOARD_SCRIPT_ARENA_EXAMPLE as U, evaluateBoardAnimations as V, BOARD_SCRIPT_DRAWING_EXAMPLE as W, CORNER_RESIZE_HANDLES as X, BOARD_SCRIPT_TILT_EXAMPLE as Y, boardZoomFloor as Z, boardPathTrack as _, rotatePointAround as _t, BOARD_THEME_DATA as a, frameEdgeHandleAt as at, boardSequencePatch as b, screenPoint as bt, boardFrameRegions as c, itemBounds as ct, boardRegionStep as d, pointToWorld as dt, clampZoom as et, boardModelFormat as f, rectCenter as ft, isBoardModelItem as g, rotateFrames as gt, inferBoardMediaKind as h, resizeFrame as ht, withBoardModelFacts as i, frameCornerRotationHandleAt as it, boardCameraScale as j, findBoardKeyTrack as k, boardNavigableFrames as l, normalizeRotation as lt, getMediaResourceTitle as m, rectsIntersect as mt, boardModelPlayback as n, effectBounds as nt, BOARD_THEME_IDS as o, frameHandlePosition as ot, boardModelViewKey as p, rectContainsPoint as pt, BOARD_SCRIPT_SENSES_EXAMPLE as q, readBoardModelFacts as r, frameContainsPoint as rt, boardFrameRegion as s, frameRect as st, boardModelJsonLength as t, degToRad as tt, boardReadingOrder as u, normalizeViewport as ut, boardPlacePatch as v, rotationHandlePosition as vt, boardRemoveTime as w, visibleWorldRect as wt, boardInsertTime as x, selectionBounds as xt, boardSequence as y, scaleFrames as yt, boardAnimatesScriptParams as z };
@@ -1,6 +1,6 @@
1
- import { C as error, D as json, E as handleHttp, O as jsonRequested, _ as failSpaceTarget, g as explicitSpace, j as table, t as createClient, x as resolveSpaceRef } from "./client.js";
2
1
  import { a as parseGenerationPolicyFromEnv, i as getAllowedGenerationModelIds, r as filterGenerationDeclarationsByPolicy } from "./policy.js";
3
- //#region ../protocol/src/generation/catalog.ts
2
+ import { C as error, D as json, E as handleHttp, O as jsonRequested, _ as failSpaceTarget, g as explicitSpace, j as table, t as createClient, x as resolveSpaceRef } from "./client.js";
3
+ // ../protocol/dist/generation/catalog.js
4
4
  function isGenerationModelHidden(model) {
5
5
  return model.hidden === true;
6
6
  }
@@ -8,8 +8,7 @@ function filterDiscoverableGenerationModels(models, options = {}) {
8
8
  const includeModelIds = new Set(options.includeModelIds);
9
9
  return models.filter((model) => !isGenerationModelHidden(model) || includeModelIds.has(model.model));
10
10
  }
11
- //#endregion
12
- //#region src/commands/models.ts
11
+ // src/commands/models.ts
13
12
  function toMultimodalModelSummary(model) {
14
13
  return {
15
14
  model: model.model,
@@ -238,5 +237,4 @@ Examples:
238
237
  }
239
238
  });
240
239
  }
241
- //#endregion
242
240
  export { registerModels };
@@ -1,6 +1,6 @@
1
1
  import { $ as parseSpaceRef } from "./client.js";
2
2
  import { posix, resolve } from "node:path";
3
- //#region src/space-files/operands.ts
3
+ // src/space-files/operands.ts
4
4
  var InvalidFileOperandError = class extends Error {
5
5
  name = "InvalidFileOperandError";
6
6
  };
@@ -42,5 +42,4 @@ function parseCopyOperand(raw, currentSpaceDeclared) {
42
42
  path: normalizeSpacePath(raw)
43
43
  };
44
44
  }
45
- //#endregion
46
45
  export { parseSpaceFileOperand as i, WORKSPACE_ROOT as n, parseCopyOperand as r, InvalidFileOperandError as t };
@@ -1,7 +1,7 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { dirname, join } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
- //#region src/package-paths.ts
4
+ // src/package-paths.ts
5
5
  const root = (() => {
6
6
  let dir = dirname(fileURLToPath(import.meta.url));
7
7
  while (!existsSync(join(dir, "package.json")) && dirname(dir) !== dir) dir = dirname(dir);
@@ -9,5 +9,4 @@ const root = (() => {
9
9
  })();
10
10
  const packagePath = (...segments) => join(root, ...segments);
11
11
  const standaloneModule = (name) => import.meta.url.endsWith(".ts") ? packagePath("src", `${name}.ts`) : packagePath("dist", `${name}.js`);
12
- //#endregion
13
12
  export { standaloneModule as n, packagePath as t };
@@ -1,4 +1,4 @@
1
- //#region ../protocol/src/generation/policy.ts
1
+ // ../protocol/dist/generation/policy.js
2
2
  const GENERATION_POLICY_ENV_KEY = "COHUB_GENERATION_POLICY_B64";
3
3
  var GenerationPolicyError = class extends Error {
4
4
  constructor(message) {
@@ -217,5 +217,4 @@ function filterGenerationDeclarationsByPolicy(declarations, policy) {
217
217
  return cloned;
218
218
  });
219
219
  }
220
- //#endregion
221
220
  export { parseGenerationPolicyFromEnv as a, getAllowedGenerationModelIds as i, assertGenerationRequestAllowedByPolicy as n, filterGenerationDeclarationsByPolicy as r, GenerationPolicyError as t };
@@ -2,7 +2,7 @@ import { homedir } from "node:os";
2
2
  import { dirname, join } from "node:path";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
5
- //#region src/runtime/preferences.ts
5
+ // src/runtime/preferences.ts
6
6
  const DEFAULTS = { keepAwake: true };
7
7
  const runtimePreferencesPath = () => join(homedir(), ".config", "cohub", "runtime-preferences.json");
8
8
  async function readRuntimePreferences(path = runtimePreferencesPath()) {
@@ -25,5 +25,4 @@ async function writeRuntimePreferences(preferences, path = runtimePreferencesPat
25
25
  await rm(temporary, { force: true });
26
26
  }
27
27
  }
28
- //#endregion
29
28
  export { writeRuntimePreferences as n, readRuntimePreferences as t };
@@ -1,6 +1,6 @@
1
- import { C as error, D as json, E as handleHttp, O as jsonRequested, k as ok, t as createClient } from "./client.js";
2
1
  import { t as uploadAvatarAsset } from "./avatar.js";
3
- //#region src/commands/profile.ts
2
+ import { C as error, D as json, E as handleHttp, O as jsonRequested, k as ok, t as createClient } from "./client.js";
3
+ // src/commands/profile.ts
4
4
  function registerProfile(program) {
5
5
  const profileCmd = program.command("profile").description("Manage your profile");
6
6
  profileCmd.command("get <username>").description("Show a public user profile").option("--json", "Output as JSON").action(async (username, opts) => {
@@ -60,5 +60,4 @@ function registerProfile(program) {
60
60
  }
61
61
  });
62
62
  }
63
- //#endregion
64
63
  export { registerProfile };
@@ -1,5 +1,5 @@
1
1
  import { D as json, E as handleHttp, O as jsonRequested, j as table, t as createClient } from "./client.js";
2
- //#region src/commands/prompts.ts
2
+ // src/commands/prompts.ts
3
3
  function registerPrompts(program) {
4
4
  program.command("prompts").description("Prompt template management").command("ls").alias("list").description("List prompt templates").option("--space <id>", "Filter by space").option("--json", "Output as JSON").action(async (opts) => {
5
5
  const client = createClient();
@@ -37,5 +37,4 @@ function registerPrompts(program) {
37
37
  }
38
38
  });
39
39
  }
40
- //#endregion
41
40
  export { registerPrompts };
@@ -1,2 +1 @@
1
- import { n as registerPublic } from "./public2.js";
2
- export { registerPublic };
1
+ export { n as registerPublic } from "./public2.js";