@bud.sh/app 0.5.1 → 0.6.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 (115) hide show
  1. package/README.md +41 -31
  2. package/dist/client/assets/bud/design.js +1 -1
  3. package/dist/client/assets/canvas-Bih9EdKJ.js +1 -0
  4. package/dist/client/assets/difference-worker-Bzg-rizy.js +8 -0
  5. package/dist/client/assets/dist-CdE5wBkg.js +5 -0
  6. package/dist/client/assets/files-1dLuoM2f.js +1 -0
  7. package/dist/client/assets/i18n-CkO6VFI0.js +1 -0
  8. package/dist/client/assets/index-Cn2mxroU.css +2 -0
  9. package/dist/client/assets/{index-Dn2pfmXf.js → index-DtISWZp9.js} +2 -2
  10. package/dist/client/assets/pages-BJ-tNJ4J.js +1 -0
  11. package/dist/client/assets/{project-branches-CMGRmrqr.js → project-branches-Ce3rXrkc.js} +1 -1
  12. package/dist/client/assets/project-comments-CPUONfs8.js +1 -0
  13. package/dist/client/assets/project-thread-links-C-TGkq59.js +1 -0
  14. package/dist/client/assets/{project-threads-ZbKDh78d.js → project-threads-Bv7IDBgi.js} +105 -105
  15. package/dist/client/assets/project-work-DAE9-olg.js +1 -0
  16. package/dist/client/assets/{task-design-BPpc4Gd7.js → task-design-CwySIAOl.js} +3 -3
  17. package/dist/client/assets/tasks-KWsCLi_h.js +3 -0
  18. package/dist/client/assets/wasm-inline-DSUyFn1L.js +1 -0
  19. package/dist/client/assets/workspace-CVdcfaaB.js +2 -0
  20. package/dist/client/index.html +3 -3
  21. package/dist/hosted/assets/{canvas-BYTOp1p7.js → canvas-AII16n9i.js} +97 -6
  22. package/dist/hosted/assets/{comment-data-Cn5y2VxV.js → comment-data-BXfMElfx.js} +1998 -381
  23. package/dist/hosted/assets/dist-BCSTeNf4.js +4785 -0
  24. package/dist/hosted/assets/{files-B1P2_24q.js → files-D_1yeAVO.js} +10 -5
  25. package/dist/hosted/assets/{pages-B0ZlVdci.js → pages-CN_SbKWA.js} +3 -3
  26. package/dist/hosted/assets/{project-branches-DlCWmfRo.js → project-branches-Bxp0DCwg.js} +1 -1
  27. package/dist/hosted/assets/{project-thread-links-BZXQ200n.js → project-thread-links-KqQoKBLE.js} +76 -4
  28. package/dist/{node-host/assets/screen-DapOVrga.js → hosted/assets/screen-DpAcDUKR.js} +25 -1
  29. package/dist/hosted/assets/tasks-D66LlwxM.js +1423 -0
  30. package/dist/hosted/assets/wasm-inline-Dl9tqabx.js +4 -0
  31. package/dist/hosted/hosted.js +7885 -6219
  32. package/dist/node/assets/Stream-CAm1eJ2n.js +16604 -0
  33. package/dist/{server/assets/bridge-B_Blt55E.js → node/assets/bridge-DQSBYHmw.js} +124 -290
  34. package/dist/node/assets/config-9_jWwNBh.js +1067 -0
  35. package/dist/node/assets/load-config.server-CMVtRVmO.js +261 -0
  36. package/dist/node/assets/module-3GgtT4Xs.js +308 -0
  37. package/dist/node/assets/server-DTQFuoX2.js +846 -0
  38. package/dist/node/assets/src-D-kG1GxB.js +2 -0
  39. package/dist/node/assets/{src-CerrKjID.js → src-Dwe9APUx.js} +93 -3
  40. package/dist/node/assets/src-DysjfbM8.js +8592 -0
  41. package/dist/node/bridge.js +1 -845
  42. package/dist/node/cli.js +206 -0
  43. package/dist/node/design.js +811 -8
  44. package/dist/node/index.js +2 -739
  45. package/dist/node/plugins.js +5711 -0
  46. package/dist/node/server.js +1 -6746
  47. package/dist/node/vite.js +121 -0
  48. package/dist/{server/assets/canvas-CkMK4hoN.js → node-host/assets/canvas-BeDoufy1.js} +97 -7
  49. package/dist/node-host/assets/{comment-data-yfWEdDQL.js → comment-data-DE2T9yTj.js} +1974 -355
  50. package/dist/node-host/assets/dist-BCSTeNf4.js +4785 -0
  51. package/dist/node-host/assets/{files-anHi-apm.js → files-Dl-PTS09.js} +11 -6
  52. package/dist/node-host/assets/{pages-CW4aF6dK.js → pages-DL2sk6_U.js} +3 -3
  53. package/dist/node-host/assets/{project-branches-D7rVCxQX.js → project-branches-DGp5ELct.js} +1 -1
  54. package/dist/{server/assets/project-thread-links-lLS_rq7c.js → node-host/assets/project-thread-links-CgBV3Jcm.js} +76 -5
  55. package/dist/{hosted/assets/screen-CfdC3NbR.js → node-host/assets/screen-B55yyVfb.js} +25 -1
  56. package/dist/node-host/assets/tasks-DZRNkoxe.js +1425 -0
  57. package/dist/node-host/assets/wasm-inline-Dl9tqabx.js +4 -0
  58. package/dist/node-host/node-host.js +6127 -4438
  59. package/dist/server/assets/{branch-previews-ClkoJ0lM.js → branch-previews-DedrpnVR.js} +1555 -673
  60. package/dist/{node-host/assets/canvas-DxmcFZCh.js → server/assets/canvas-CJWQ-jjv.js} +98 -6
  61. package/dist/server/assets/{comment-data-NLeHG89b.js → comment-data-Rg42ToTW.js} +1660 -26
  62. package/dist/server/assets/dist-BCSTeNf4.js +4785 -0
  63. package/dist/server/assets/{events-iHpLGr3k.js → events-BH_rAu7O.js} +155 -20
  64. package/dist/server/assets/{files-CRdl489E.js → files-CPJqKeMo.js} +12 -7
  65. package/dist/server/assets/{listener-BAYn9Q-u.js → listener-D61O6PzF.js} +708 -12
  66. package/dist/server/assets/{pages-DXVlJlBC.js → pages-KJY_Ba92.js} +4 -4
  67. package/dist/server/assets/{project-branches-CwTsf6WQ.js → project-branches-qG9ACZvo.js} +2 -2
  68. package/dist/{node-host/assets/project-thread-links-m-OLpsD9.js → server/assets/project-thread-links-CqK0lqCF.js} +77 -4
  69. package/dist/{node-host/assets/tasks-request-B0aeNocI.js → server/assets/project-work-DoIwxWMm.js} +87 -2
  70. package/dist/server/assets/run-BJ8r5jSh.js +572 -0
  71. package/dist/server/assets/{screen-B1zH_1O3.js → screen-CBrHPFug.js} +26 -2
  72. package/dist/server/assets/{server-DxK-UB_Z.js → server-Dkbp5stG.js} +1521 -793
  73. package/dist/server/assets/{services-BRrgXYlT.js → services-BTfig8A8.js} +234 -997
  74. package/dist/server/assets/tasks-Bgu5Lg9Y.js +1427 -0
  75. package/dist/server/assets/wasm-inline-Dl9tqabx.js +4 -0
  76. package/dist/server/capture.js +1 -2
  77. package/dist/server/migration.js +569 -12
  78. package/dist/server/runtime.js +7 -5
  79. package/dist/server/server.js +3 -3
  80. package/dist/types/assets/{config-DIC2cf_S.d.ts → config-CvcYmE2s.d.ts} +188 -50
  81. package/dist/types/assets/{contract-CAT-XFNq.d.ts → contract-B7yuuqSn.d.ts} +44 -2
  82. package/dist/types/assets/{items-CaVkByHk.d.ts → items-BQdaVksf.d.ts} +12 -1
  83. package/dist/types/assets/memory-state-BBW-FAVA.d.ts +236 -0
  84. package/dist/types/assets/picker-Be5Gx4WR.d.ts +9 -0
  85. package/dist/types/assets/{task-design-xJOhRNWh.d.ts → task-design-BDHKFHpp.d.ts} +3 -1
  86. package/dist/types/bridge.d.ts +1 -1
  87. package/dist/types/companion.d.ts +3 -3
  88. package/dist/types/design.d.ts +2 -2
  89. package/dist/types/hosted.d.ts +3 -3
  90. package/dist/types/index.d.ts +2 -2
  91. package/dist/types/node-host.d.ts +2 -2
  92. package/dist/types/plugins.d.ts +445 -0
  93. package/dist/types/screen.d.ts +2 -2
  94. package/dist/types/server.d.ts +2 -228
  95. package/dist/types/vite.d.ts +16 -0
  96. package/package.json +19 -3
  97. package/dist/client/assets/canvas-8GXJIuDK.js +0 -1
  98. package/dist/client/assets/difference-worker-C99ychYw.js +0 -8
  99. package/dist/client/assets/files-DkWt1l9H.js +0 -1
  100. package/dist/client/assets/i18n-hH_Ba5QO.js +0 -1
  101. package/dist/client/assets/index-tpHYVXma.css +0 -2
  102. package/dist/client/assets/pages-BVd6MQmu.js +0 -1
  103. package/dist/client/assets/project-comments-D1IIQwsW.js +0 -1
  104. package/dist/client/assets/project-thread-links-DKwe_SYb.js +0 -1
  105. package/dist/client/assets/project-work-D4DZqBCZ.js +0 -1
  106. package/dist/client/assets/tasks-Cn0VOZ9Z.js +0 -1
  107. package/dist/client/assets/tasks-request-BLyOzokZ.js +0 -1
  108. package/dist/client/assets/workspace-DGErsSg6.js +0 -2
  109. package/dist/hosted/assets/tasks-_yKh2Z6q.js +0 -649
  110. package/dist/hosted/assets/tasks-request-CFPLvLc7.js +0 -113
  111. package/dist/node-host/assets/tasks-BBK_CybR.js +0 -651
  112. package/dist/server/assets/project-work-CSZlCwH-.js +0 -88
  113. package/dist/server/assets/tasks-CGdz-uox.js +0 -652
  114. package/dist/server/assets/tasks-request-D2NBjCTl.js +0 -115
  115. package/dist/types/assets/picker-D1Bw3ndx.d.ts +0 -14
@@ -0,0 +1,121 @@
1
+ import { n as pickerModules, t as bridgeScript } from "./assets/bridge-DQSBYHmw.js";
2
+ import { n as resolveTargetOrigin, r as ProjectConfig, t as createConfigRuntime } from "./assets/load-config.server-CMVtRVmO.js";
3
+ import { resolve } from "node:path";
4
+ //#region src/host/vite.server.ts
5
+ /**
6
+ * Hosts Bud's app beside an existing Vite server, whose live updates refresh Bud's page previews.
7
+ * With `BUD_SANDBOX=1`, as in a factory sandbox's dev server, it only serves the page bridge and
8
+ * the picker, for Agent view's browser.
9
+ * @param options - Optional workspace development mode.
10
+ * @returns A development-only Vite plugin with an owned companion lifecycle.
11
+ */
12
+ function bud(options = {}) {
13
+ let lifetimes = /* @__PURE__ */ new WeakMap();
14
+ let pickers = /* @__PURE__ */ new Map();
15
+ return {
16
+ name: "bud:companion",
17
+ apply: (_config, { command }) => command === "serve" && !process.env.BUD_BRANCH_BUILD,
18
+ async configureServer(vite) {
19
+ let runtime = createConfigRuntime();
20
+ let controller = new AbortController();
21
+ let companion;
22
+ let starting;
23
+ let closing;
24
+ let restarting = false;
25
+ let filenames = ["bud.config.ts", "bud.config.js"].map((name) => resolve(vite.config.root, name));
26
+ let changed = (filename) => {
27
+ if (controller.signal.aborted || restarting || !filenames.includes(resolve(filename))) return;
28
+ restarting = true;
29
+ vite.restart().catch((error) => {
30
+ restarting = false;
31
+ vite.config.logger.error(`Bud: ${error instanceof Error ? error.message : "Config restart failed."}`);
32
+ });
33
+ };
34
+ let listening = () => {
35
+ if (controller.signal.aborted || starting) return;
36
+ starting = start().catch((error) => {
37
+ if (!controller.signal.aborted) vite.config.logger.error(`Bud: ${error instanceof Error ? error.message : "Companion startup failed."}`);
38
+ throw error;
39
+ });
40
+ starting.catch(() => {});
41
+ };
42
+ let cleanup = () => closing ??= (async () => {
43
+ controller.abort();
44
+ vite.httpServer?.off("listening", listening);
45
+ for (let event of [
46
+ "change",
47
+ "add",
48
+ "unlink"
49
+ ]) vite.watcher.off(event, changed);
50
+ await starting?.catch(() => {});
51
+ try {
52
+ await companion?.close();
53
+ } finally {
54
+ await runtime.dispose();
55
+ }
56
+ })();
57
+ let lifetime = { close: cleanup };
58
+ for (let environment of Object.values(vite.environments)) lifetimes.set(environment, lifetime);
59
+ let loaded;
60
+ async function load() {
61
+ return runtime.runPromise(ProjectConfig.use((service) => service.load(vite.config.root)), { signal: controller.signal });
62
+ }
63
+ async function start() {
64
+ let targetOrigin = await runtime.runPromise(resolveTargetOrigin(loaded.config, vite.httpServer?.address(), {
65
+ host: vite.config.server.host,
66
+ https: Boolean(vite.config.server.https)
67
+ }), { signal: controller.signal });
68
+ let { startBud } = await import(
69
+ /* @vite-ignore */
70
+ import.meta.resolve("@bud.sh/app/companion")
71
+ );
72
+ controller.signal.throwIfAborted();
73
+ companion = await startBud({
74
+ root: loaded.root,
75
+ config: loaded.config,
76
+ targetOrigin,
77
+ development: options.development,
78
+ signal: controller.signal
79
+ });
80
+ vite.config.logger.info(`\n Bud → ${companion.origin}\n`);
81
+ }
82
+ try {
83
+ loaded = await load();
84
+ pickers = pickerModules(loaded.config.picker);
85
+ filenames = [.../* @__PURE__ */ new Set([...filenames, ...["bud.config.ts", "bud.config.js"].map((name) => resolve(loaded.root, name))])];
86
+ vite.watcher.add(filenames);
87
+ for (let event of [
88
+ "change",
89
+ "add",
90
+ "unlink"
91
+ ]) vite.watcher.on(event, changed);
92
+ if (process.env.BUD_SANDBOX === "1") return;
93
+ if (vite.httpServer?.listening) listening();
94
+ else vite.httpServer?.once("listening", listening);
95
+ } catch (error) {
96
+ await cleanup();
97
+ throw error;
98
+ }
99
+ },
100
+ resolveId(id) {
101
+ return pickers.has(id) ? id : void 0;
102
+ },
103
+ load(id) {
104
+ return pickers.get(id);
105
+ },
106
+ transformIndexHtml: {
107
+ order: "post",
108
+ handler: () => [{
109
+ tag: "script",
110
+ attrs: { type: "module" },
111
+ children: bridgeScript,
112
+ injectTo: "head"
113
+ }]
114
+ },
115
+ async closeBundle() {
116
+ await lifetimes.get(this.environment)?.close();
117
+ }
118
+ };
119
+ }
120
+ //#endregion
121
+ export { bud };
@@ -1,8 +1,7 @@
1
- import { Bn as Icon } from "./events-iHpLGr3k.js";
2
- import { Bt as Button, En as t, H as captureCanvasPoint, On as Text, Rt as Loader, Sn as writePreference, V as CanvasWorkspace, W as BranchSidebar, fn as ToolbarSeparator, gn as IconButton, hn as Select, l as projectStore, pn as WorkspaceLayout, t as commentsUnavailable, ut as conversationHref, vn as Tooltip, xn as readPreference } from "./comment-data-NLeHG89b.js";
3
- import { i as pictureKey, n as createProjectPreviews, t as createProjectBranches } from "./project-branches-CwTsf6WQ.js";
4
- import { n as createProjectComments, r as loadComments, t as defineScreen } from "./screen-B1zH_1O3.js";
5
- import { t as ProjectThreadLinks } from "./project-thread-links-lLS_rq7c.js";
1
+ import { Gt as Loader, Jt as ToolbarSeparator, K as BranchSidebar, Qt as IconButton, U as CanvasWorkspace, W as captureCanvasPoint, Yt as WorkspaceLayout, Zt as Select, cn as t, dn as Icon, en as Tooltip, in as writePreference, l as projectStore, mt as conversationHref, qt as Button, rn as readPreference, t as commentsUnavailable, un as Text } from "./comment-data-DE2T9yTj.js";
2
+ import { i as pictureKey, n as createProjectPreviews, t as createProjectBranches } from "./project-branches-DGp5ELct.js";
3
+ import { n as createProjectComments, r as loadComments, t as defineScreen } from "./screen-B55yyVfb.js";
4
+ import { n as ProjectThreadLinks, t as ProjectMakeTask } from "./project-thread-links-CgBV3Jcm.js";
6
5
  import { on, ref } from "remix/component";
7
6
  import { Fragment, jsx, jsxs } from "remix/component/jsx-runtime";
8
7
  //#region app/client/preview-image.tsx
@@ -292,6 +291,92 @@ function PreviewRefresh(handle) {
292
291
  };
293
292
  }
294
293
  //#endregion
294
+ //#region app/client/task-context.ts
295
+ var CROP = {
296
+ width: 1200,
297
+ height: 800
298
+ };
299
+ var QUALITY = .82;
300
+ /**
301
+ * What a task made from a canvas comment takes along: the page around the comment's point with
302
+ * the point marked, and the element there with its source.
303
+ * @param previews - The canvas's pictures, for the branch the comment is on.
304
+ * @param thread - The discussion.
305
+ * @param sizes - The project's viewports.
306
+ * @returns The context, or undefined when the comment has no picture to take it from.
307
+ */
308
+ async function canvasTaskContext(previews, thread, sizes) {
309
+ let anchor = thread.anchor;
310
+ if (!anchor || "type" in anchor) return void 0;
311
+ let size = sizes.find((candidate) => candidate.width === anchor.viewport) ?? sizes[0];
312
+ if (!size) return void 0;
313
+ let picture = await previews.picture(anchor.pageId, "light", size);
314
+ if (!picture) return void 0;
315
+ let { capture, images } = picture;
316
+ let pin = capture.pins?.find((entry) => entry.id === thread.id && entry.x !== null);
317
+ let point = pin && pin.x !== null && pin.y !== null ? {
318
+ x: pin.x,
319
+ y: pin.y
320
+ } : {
321
+ x: anchor.offsetX * capture.width,
322
+ y: anchor.offsetY
323
+ };
324
+ let [image, element] = await Promise.all([cropAround(capture, images, point).catch(() => void 0), previews.describe(anchor.pageId, capture, point.x, point.y).catch(() => null)]);
325
+ return {
326
+ ...image ? { image } : {},
327
+ element,
328
+ point
329
+ };
330
+ }
331
+ /**
332
+ * Cuts the page around a point out of a capture's slices and marks the point.
333
+ * @param capture - The capture's size, scale and slices.
334
+ * @param images - The slices' images, top to bottom.
335
+ * @param point - The point in CSS pixels.
336
+ * @returns The JPEG as base64.
337
+ */
338
+ async function cropAround(capture, images, point) {
339
+ let width = Math.min(CROP.width, capture.width);
340
+ let height = Math.min(CROP.height, capture.height);
341
+ let left = Math.max(0, Math.min(capture.width - width, Math.round(point.x - width / 2)));
342
+ let top = Math.max(0, Math.min(capture.height - height, Math.round(point.y - height / 2)));
343
+ let canvas = new OffscreenCanvas(width, height);
344
+ let context = canvas.getContext("2d");
345
+ if (!context) throw new Error("No canvas.");
346
+ context.fillStyle = "#fff";
347
+ context.fillRect(0, 0, width, height);
348
+ let tileTop = 0;
349
+ for (let [index, tile] of capture.tiles.entries()) {
350
+ let tileBottom = tileTop + tile.height;
351
+ let from = Math.max(top, tileTop);
352
+ let to = Math.min(top + height, tileBottom);
353
+ if (to > from && images[index]) {
354
+ let bitmap = await createImageBitmap(images[index]);
355
+ context.drawImage(bitmap, left * capture.scale, (from - tileTop) * capture.scale, width * capture.scale, (to - from) * capture.scale, 0, from - top, width, to - from);
356
+ bitmap.close();
357
+ }
358
+ tileTop = tileBottom;
359
+ }
360
+ let x = point.x - left;
361
+ let y = point.y - top;
362
+ context.lineWidth = 6;
363
+ context.strokeStyle = "#fff";
364
+ context.beginPath();
365
+ context.arc(x, y, 18, 0, Math.PI * 2);
366
+ context.stroke();
367
+ context.lineWidth = 3;
368
+ context.strokeStyle = "#ef4444";
369
+ context.stroke();
370
+ let blob = await canvas.convertToBlob({
371
+ type: "image/jpeg",
372
+ quality: QUALITY
373
+ });
374
+ let bytes = new Uint8Array(await blob.arrayBuffer());
375
+ let binary = "";
376
+ for (let index = 0; index < bytes.length; index += 32768) binary += String.fromCharCode(...bytes.subarray(index, index + 32768));
377
+ return btoa(binary);
378
+ }
379
+ //#endregion
295
380
  //#region app/client/project-differences.ts
296
381
  var results = /* @__PURE__ */ new Map();
297
382
  function worker() {
@@ -1009,7 +1094,12 @@ function ProjectCanvas(handle) {
1009
1094
  await comments.loadThread(thread.id, true);
1010
1095
  }
1011
1096
  }),
1012
- renderThreadActions: (thread) => /* @__PURE__ */ jsx(ProjectThreadLinks, {
1097
+ renderThreadActions: (thread) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ProjectMakeTask, {
1098
+ thread,
1099
+ canMake: comments.snapshot.capabilities.link && project.storage.work?.state === "ready",
1100
+ busy: comments.busy,
1101
+ onMake: async (id) => comments.makeTask(id, await canvasTaskContext(previews, thread, sizes).catch(() => void 0))
1102
+ }), /* @__PURE__ */ jsx(ProjectThreadLinks, {
1013
1103
  part: "action",
1014
1104
  project,
1015
1105
  thread,
@@ -1019,7 +1109,7 @@ function ProjectCanvas(handle) {
1019
1109
  await comments.load();
1020
1110
  await comments.loadThread(thread.id, true);
1021
1111
  }
1022
- }),
1112
+ })] }),
1023
1113
  initialThreadId: requestedThread,
1024
1114
  loaded: comments.loaded,
1025
1115
  busy: comments.busy,