@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.
- package/README.md +41 -31
- package/dist/client/assets/bud/design.js +1 -1
- package/dist/client/assets/canvas-Bih9EdKJ.js +1 -0
- package/dist/client/assets/difference-worker-Bzg-rizy.js +8 -0
- package/dist/client/assets/dist-CdE5wBkg.js +5 -0
- package/dist/client/assets/files-1dLuoM2f.js +1 -0
- package/dist/client/assets/i18n-CkO6VFI0.js +1 -0
- package/dist/client/assets/index-Cn2mxroU.css +2 -0
- package/dist/client/assets/{index-Dn2pfmXf.js → index-DtISWZp9.js} +2 -2
- package/dist/client/assets/pages-BJ-tNJ4J.js +1 -0
- package/dist/client/assets/{project-branches-CMGRmrqr.js → project-branches-Ce3rXrkc.js} +1 -1
- package/dist/client/assets/project-comments-CPUONfs8.js +1 -0
- package/dist/client/assets/project-thread-links-C-TGkq59.js +1 -0
- package/dist/client/assets/{project-threads-ZbKDh78d.js → project-threads-Bv7IDBgi.js} +105 -105
- package/dist/client/assets/project-work-DAE9-olg.js +1 -0
- package/dist/client/assets/{task-design-BPpc4Gd7.js → task-design-CwySIAOl.js} +3 -3
- package/dist/client/assets/tasks-KWsCLi_h.js +3 -0
- package/dist/client/assets/wasm-inline-DSUyFn1L.js +1 -0
- package/dist/client/assets/workspace-CVdcfaaB.js +2 -0
- package/dist/client/index.html +3 -3
- package/dist/hosted/assets/{canvas-BYTOp1p7.js → canvas-AII16n9i.js} +97 -6
- package/dist/hosted/assets/{comment-data-Cn5y2VxV.js → comment-data-BXfMElfx.js} +1998 -381
- package/dist/hosted/assets/dist-BCSTeNf4.js +4785 -0
- package/dist/hosted/assets/{files-B1P2_24q.js → files-D_1yeAVO.js} +10 -5
- package/dist/hosted/assets/{pages-B0ZlVdci.js → pages-CN_SbKWA.js} +3 -3
- package/dist/hosted/assets/{project-branches-DlCWmfRo.js → project-branches-Bxp0DCwg.js} +1 -1
- package/dist/hosted/assets/{project-thread-links-BZXQ200n.js → project-thread-links-KqQoKBLE.js} +76 -4
- package/dist/{node-host/assets/screen-DapOVrga.js → hosted/assets/screen-DpAcDUKR.js} +25 -1
- package/dist/hosted/assets/tasks-D66LlwxM.js +1423 -0
- package/dist/hosted/assets/wasm-inline-Dl9tqabx.js +4 -0
- package/dist/hosted/hosted.js +7885 -6219
- package/dist/node/assets/Stream-CAm1eJ2n.js +16604 -0
- package/dist/{server/assets/bridge-B_Blt55E.js → node/assets/bridge-DQSBYHmw.js} +124 -290
- package/dist/node/assets/config-9_jWwNBh.js +1067 -0
- package/dist/node/assets/load-config.server-CMVtRVmO.js +261 -0
- package/dist/node/assets/module-3GgtT4Xs.js +308 -0
- package/dist/node/assets/server-DTQFuoX2.js +846 -0
- package/dist/node/assets/src-D-kG1GxB.js +2 -0
- package/dist/node/assets/{src-CerrKjID.js → src-Dwe9APUx.js} +93 -3
- package/dist/node/assets/src-DysjfbM8.js +8592 -0
- package/dist/node/bridge.js +1 -845
- package/dist/node/cli.js +206 -0
- package/dist/node/design.js +811 -8
- package/dist/node/index.js +2 -739
- package/dist/node/plugins.js +5711 -0
- package/dist/node/server.js +1 -6746
- package/dist/node/vite.js +121 -0
- package/dist/{server/assets/canvas-CkMK4hoN.js → node-host/assets/canvas-BeDoufy1.js} +97 -7
- package/dist/node-host/assets/{comment-data-yfWEdDQL.js → comment-data-DE2T9yTj.js} +1974 -355
- package/dist/node-host/assets/dist-BCSTeNf4.js +4785 -0
- package/dist/node-host/assets/{files-anHi-apm.js → files-Dl-PTS09.js} +11 -6
- package/dist/node-host/assets/{pages-CW4aF6dK.js → pages-DL2sk6_U.js} +3 -3
- package/dist/node-host/assets/{project-branches-D7rVCxQX.js → project-branches-DGp5ELct.js} +1 -1
- package/dist/{server/assets/project-thread-links-lLS_rq7c.js → node-host/assets/project-thread-links-CgBV3Jcm.js} +76 -5
- package/dist/{hosted/assets/screen-CfdC3NbR.js → node-host/assets/screen-B55yyVfb.js} +25 -1
- package/dist/node-host/assets/tasks-DZRNkoxe.js +1425 -0
- package/dist/node-host/assets/wasm-inline-Dl9tqabx.js +4 -0
- package/dist/node-host/node-host.js +6127 -4438
- package/dist/server/assets/{branch-previews-ClkoJ0lM.js → branch-previews-DedrpnVR.js} +1555 -673
- package/dist/{node-host/assets/canvas-DxmcFZCh.js → server/assets/canvas-CJWQ-jjv.js} +98 -6
- package/dist/server/assets/{comment-data-NLeHG89b.js → comment-data-Rg42ToTW.js} +1660 -26
- package/dist/server/assets/dist-BCSTeNf4.js +4785 -0
- package/dist/server/assets/{events-iHpLGr3k.js → events-BH_rAu7O.js} +155 -20
- package/dist/server/assets/{files-CRdl489E.js → files-CPJqKeMo.js} +12 -7
- package/dist/server/assets/{listener-BAYn9Q-u.js → listener-D61O6PzF.js} +708 -12
- package/dist/server/assets/{pages-DXVlJlBC.js → pages-KJY_Ba92.js} +4 -4
- package/dist/server/assets/{project-branches-CwTsf6WQ.js → project-branches-qG9ACZvo.js} +2 -2
- package/dist/{node-host/assets/project-thread-links-m-OLpsD9.js → server/assets/project-thread-links-CqK0lqCF.js} +77 -4
- package/dist/{node-host/assets/tasks-request-B0aeNocI.js → server/assets/project-work-DoIwxWMm.js} +87 -2
- package/dist/server/assets/run-BJ8r5jSh.js +572 -0
- package/dist/server/assets/{screen-B1zH_1O3.js → screen-CBrHPFug.js} +26 -2
- package/dist/server/assets/{server-DxK-UB_Z.js → server-Dkbp5stG.js} +1521 -793
- package/dist/server/assets/{services-BRrgXYlT.js → services-BTfig8A8.js} +234 -997
- package/dist/server/assets/tasks-Bgu5Lg9Y.js +1427 -0
- package/dist/server/assets/wasm-inline-Dl9tqabx.js +4 -0
- package/dist/server/capture.js +1 -2
- package/dist/server/migration.js +569 -12
- package/dist/server/runtime.js +7 -5
- package/dist/server/server.js +3 -3
- package/dist/types/assets/{config-DIC2cf_S.d.ts → config-CvcYmE2s.d.ts} +188 -50
- package/dist/types/assets/{contract-CAT-XFNq.d.ts → contract-B7yuuqSn.d.ts} +44 -2
- package/dist/types/assets/{items-CaVkByHk.d.ts → items-BQdaVksf.d.ts} +12 -1
- package/dist/types/assets/memory-state-BBW-FAVA.d.ts +236 -0
- package/dist/types/assets/picker-Be5Gx4WR.d.ts +9 -0
- package/dist/types/assets/{task-design-xJOhRNWh.d.ts → task-design-BDHKFHpp.d.ts} +3 -1
- package/dist/types/bridge.d.ts +1 -1
- package/dist/types/companion.d.ts +3 -3
- package/dist/types/design.d.ts +2 -2
- package/dist/types/hosted.d.ts +3 -3
- package/dist/types/index.d.ts +2 -2
- package/dist/types/node-host.d.ts +2 -2
- package/dist/types/plugins.d.ts +445 -0
- package/dist/types/screen.d.ts +2 -2
- package/dist/types/server.d.ts +2 -228
- package/dist/types/vite.d.ts +16 -0
- package/package.json +19 -3
- package/dist/client/assets/canvas-8GXJIuDK.js +0 -1
- package/dist/client/assets/difference-worker-C99ychYw.js +0 -8
- package/dist/client/assets/files-DkWt1l9H.js +0 -1
- package/dist/client/assets/i18n-hH_Ba5QO.js +0 -1
- package/dist/client/assets/index-tpHYVXma.css +0 -2
- package/dist/client/assets/pages-BVd6MQmu.js +0 -1
- package/dist/client/assets/project-comments-D1IIQwsW.js +0 -1
- package/dist/client/assets/project-thread-links-DKwe_SYb.js +0 -1
- package/dist/client/assets/project-work-D4DZqBCZ.js +0 -1
- package/dist/client/assets/tasks-Cn0VOZ9Z.js +0 -1
- package/dist/client/assets/tasks-request-BLyOzokZ.js +0 -1
- package/dist/client/assets/workspace-DGErsSg6.js +0 -2
- package/dist/hosted/assets/tasks-_yKh2Z6q.js +0 -649
- package/dist/hosted/assets/tasks-request-CFPLvLc7.js +0 -113
- package/dist/node-host/assets/tasks-BBK_CybR.js +0 -651
- package/dist/server/assets/project-work-CSZlCwH-.js +0 -88
- package/dist/server/assets/tasks-CGdz-uox.js +0 -652
- package/dist/server/assets/tasks-request-D2NBjCTl.js +0 -115
- package/dist/types/assets/picker-D1Bw3ndx.d.ts +0 -14
package/dist/types/server.d.ts
CHANGED
|
@@ -1,216 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as CanvasAnchor } from "./assets/canvas-anchor-CYU3qBPx.js";
|
|
3
|
-
import * as Cause from "effect/Cause";
|
|
4
|
-
import * as Context from "effect/Context";
|
|
5
|
-
import * as Effect from "effect/Effect";
|
|
6
|
-
import * as Stream from "effect/Stream";
|
|
1
|
+
import { a as ThreadImportInput, c as WorkError, i as WorkReader, l as WorkFailureReason, n as ThreadAdapter, o as ThreadImportResult, r as WorkAdapter, s as parseThreadImport, t as MemoryAdapterOptions } from "./assets/memory-state-BBW-FAVA.js";
|
|
7
2
|
import * as Layer from "effect/Layer";
|
|
8
|
-
//#region ../work/src/lib/code-anchor.d.ts
|
|
9
|
-
/**
|
|
10
|
-
* A code comment's place: an inclusive line range of one file version, with the selected lines and
|
|
11
|
-
* up to three lines on each side, so it can be found again after the file changes.
|
|
12
|
-
*/
|
|
13
|
-
interface CodeAnchor {
|
|
14
|
-
readonly type: "code";
|
|
15
|
-
readonly version: 1;
|
|
16
|
-
readonly path: string;
|
|
17
|
-
/** Complete-byte SHA-256 supplied by the Files service, not a mutable branch name. */
|
|
18
|
-
readonly revision: string;
|
|
19
|
-
/** The commit the lines come from, or `null` for uncommitted changes. */
|
|
20
|
-
readonly commit: string | null;
|
|
21
|
-
/** Which side of a diff the lines are on. */
|
|
22
|
-
readonly side: "old" | "new";
|
|
23
|
-
readonly startLine: number;
|
|
24
|
-
readonly endLine: number;
|
|
25
|
-
readonly context: {
|
|
26
|
-
readonly before: readonly string[];
|
|
27
|
-
readonly selected: readonly string[];
|
|
28
|
-
readonly after: readonly string[];
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region ../work/src/lib/threads.d.ts
|
|
33
|
-
declare const threadStatuses: readonly ["open", "in_progress", "needs_approval", "resolved"];
|
|
34
|
-
/** Where a discussion is in its lifecycle. */
|
|
35
|
-
type ThreadStatus = (typeof threadStatuses)[number];
|
|
36
|
-
/** Where a discussion is attached: a page capture or a code capture. */
|
|
37
|
-
type Anchor = CanvasAnchor | CodeAnchor;
|
|
38
|
-
/** A discussion shared by page captures, code captures and linked work items. */
|
|
39
|
-
interface Thread {
|
|
40
|
-
id: string;
|
|
41
|
-
status: ThreadStatus;
|
|
42
|
-
anchor: Anchor | null;
|
|
43
|
-
itemIds: string[];
|
|
44
|
-
messages: Message[];
|
|
45
|
-
messageCount: number;
|
|
46
|
-
messagesLoaded: boolean;
|
|
47
|
-
messagesTruncated: boolean;
|
|
48
|
-
createdAt: string;
|
|
49
|
-
updatedAt: string;
|
|
50
|
-
revision: string | null;
|
|
51
|
-
/** Adapter metadata, including stable source identity for imported discussions. */
|
|
52
|
-
metadata?: JsonValue;
|
|
53
|
-
}
|
|
54
|
-
/** Which discussion operations an adapter supports. */
|
|
55
|
-
interface ThreadCapabilities {
|
|
56
|
-
create: boolean;
|
|
57
|
-
reply: boolean;
|
|
58
|
-
status: boolean;
|
|
59
|
-
link: boolean;
|
|
60
|
-
sync: boolean;
|
|
61
|
-
edit: boolean;
|
|
62
|
-
delete: boolean;
|
|
63
|
-
}
|
|
64
|
-
/** The discussions an adapter lists, with its connection and capabilities. */
|
|
65
|
-
interface ThreadSnapshot {
|
|
66
|
-
connection: WorkConnection;
|
|
67
|
-
capabilities: ThreadCapabilities;
|
|
68
|
-
threads: Thread[];
|
|
69
|
-
truncated: boolean;
|
|
70
|
-
}
|
|
71
|
-
/** A new discussion: its first message and where it is attached. */
|
|
72
|
-
interface ThreadInput {
|
|
73
|
-
anchor: Anchor | null;
|
|
74
|
-
itemIds: string[];
|
|
75
|
-
body: string;
|
|
76
|
-
}
|
|
77
|
-
/** A reply, posted only while the discussion is still at `expectedRevision`. */
|
|
78
|
-
interface ThreadReplyInput {
|
|
79
|
-
body: string;
|
|
80
|
-
parentId: string | null;
|
|
81
|
-
expectedRevision: string;
|
|
82
|
-
}
|
|
83
|
-
/** A message to delete, deleted only while the discussion is still at `expectedRevision`. */
|
|
84
|
-
interface ThreadDeleteInput {
|
|
85
|
-
messageId: string;
|
|
86
|
-
expectedRevision: string;
|
|
87
|
-
}
|
|
88
|
-
/** Which discussions a list returns: by anchor kind, page or linked item. */
|
|
89
|
-
interface ThreadFilter {
|
|
90
|
-
anchorKind?: "canvas" | "code";
|
|
91
|
-
pagePath?: string;
|
|
92
|
-
itemId?: string;
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region ../work/src/server/errors.d.ts
|
|
96
|
-
/**
|
|
97
|
-
* Why a work or thread operation failed. `uncertain` means a write may have applied; callers must
|
|
98
|
-
* not retry it automatically.
|
|
99
|
-
*/
|
|
100
|
-
type WorkFailureReason = "input" | "unavailable" | "not-found" | "conflict" | "refused" | "timeout" | "uncertain" | "storage";
|
|
101
|
-
interface WorkErrorFields {
|
|
102
|
-
readonly reason: WorkFailureReason;
|
|
103
|
-
readonly message: string;
|
|
104
|
-
readonly operation?: string;
|
|
105
|
-
readonly currentRevision?: string | null;
|
|
106
|
-
readonly cause?: unknown;
|
|
107
|
-
}
|
|
108
|
-
declare const WorkErrorBase: new (fields: WorkErrorFields) => Cause.YieldableError & WorkErrorFields & {
|
|
109
|
-
readonly _tag: "WorkError";
|
|
110
|
-
};
|
|
111
|
-
/** Safe messages cross the HTTP boundary; diagnostics and credentials do not. */
|
|
112
|
-
export declare class WorkError extends WorkErrorBase {}
|
|
113
|
-
//#endregion
|
|
114
|
-
//#region ../work/src/server/import.d.ts
|
|
115
|
-
/**
|
|
116
|
-
* Trusted history from another store, keyed by its source identity; never part of a browser create
|
|
117
|
-
* or reply request.
|
|
118
|
-
*/
|
|
119
|
-
interface ThreadImportInput {
|
|
120
|
-
source: string;
|
|
121
|
-
sourceId: string;
|
|
122
|
-
thread: Thread;
|
|
123
|
-
}
|
|
124
|
-
/** The imported discussion, and whether this import created it or found it already there. */
|
|
125
|
-
interface ThreadImportResult {
|
|
126
|
-
outcome: "created" | "existing";
|
|
127
|
-
thread: Thread;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Validates complete source history before a server-side migration writes anything.
|
|
131
|
-
* @param value - The source identity and fully loaded discussion.
|
|
132
|
-
* @returns Complete, byte-bounded history, independent of the browser's message-count limit.
|
|
133
|
-
*/
|
|
134
|
-
export declare function parseThreadImport(value: unknown): ThreadImportInput;
|
|
135
|
-
//#endregion
|
|
136
|
-
//#region ../work/src/server/services.d.ts
|
|
137
|
-
/** Read-only operations bound to one request's project and resource lifetime. */
|
|
138
|
-
interface WorkReader {
|
|
139
|
-
readonly describe: Effect.Effect<WorkConnection, WorkError>;
|
|
140
|
-
readonly schema: Effect.Effect<WorkSchema, WorkError>;
|
|
141
|
-
readonly list: (query: WorkQuery) => Effect.Effect<WorkSnapshot, WorkError>;
|
|
142
|
-
readonly get: (id: string) => Effect.Effect<WorkDetail, WorkError>;
|
|
143
|
-
readonly section: (id: string, sectionId: string) => Effect.Effect<SectionData, WorkError>;
|
|
144
|
-
}
|
|
145
|
-
interface WorkAdapterOperations {
|
|
146
|
-
/** Optional request composition; readers cannot write or outlive the callback. */
|
|
147
|
-
readonly read?: <A, E>(root: string, operation: (reader: WorkReader) => Effect.Effect<A, E>) => Effect.Effect<A, E | WorkError>;
|
|
148
|
-
readonly describe: (root: string) => Effect.Effect<WorkConnection, WorkError>;
|
|
149
|
-
readonly schema: (root: string) => Effect.Effect<WorkSchema, WorkError>;
|
|
150
|
-
readonly list: (root: string, query: WorkQuery) => Effect.Effect<WorkSnapshot, WorkError>;
|
|
151
|
-
readonly get: (root: string, id: string) => Effect.Effect<WorkDetail, WorkError>;
|
|
152
|
-
readonly section: (root: string, id: string, sectionId: string) => Effect.Effect<SectionData, WorkError>;
|
|
153
|
-
readonly create: (root: string, input: WorkCreate) => Effect.Effect<WorkMutationResult, WorkError>;
|
|
154
|
-
readonly update: (root: string, id: string, patch: WorkPatch, expectedRevision: string) => Effect.Effect<WorkMutationResult, WorkError>;
|
|
155
|
-
readonly act: (root: string, id: string, actionId: string, input: WorkPatch, expectedRevision: string) => Effect.Effect<WorkMutationResult, WorkError>;
|
|
156
|
-
readonly sync?: (root: string, direction: WorkSync["direction"]) => Effect.Effect<WorkSyncResult, WorkError>;
|
|
157
|
-
/**
|
|
158
|
-
* Signals stored changes, including ones made outside Bud such as an agent using the
|
|
159
|
-
* store's CLI. Without it, open views follow only Bud's own writes.
|
|
160
|
-
*/
|
|
161
|
-
readonly watch?: (root: string) => Stream.Stream<void, WorkError>;
|
|
162
|
-
}
|
|
163
|
-
declare const WorkAdapterBase: Context.ServiceClass<WorkAdapter, "@bud.sh/work/WorkAdapter", WorkAdapterOperations>;
|
|
164
|
-
/** A backend's work items. Run programs at a request boundary with its AbortSignal. */
|
|
165
|
-
export declare class WorkAdapter extends WorkAdapterBase {}
|
|
166
|
-
interface ThreadAdapterOperations {
|
|
167
|
-
/** Server-only migration; browser requests cannot supply stored authors or timestamps. */
|
|
168
|
-
readonly import?: (root: string, input: ThreadImportInput) => Effect.Effect<ThreadImportResult, WorkError>;
|
|
169
|
-
readonly list: (root: string, filter: ThreadFilter) => Effect.Effect<ThreadSnapshot, WorkError>;
|
|
170
|
-
readonly get: (root: string, id: string) => Effect.Effect<Thread, WorkError>;
|
|
171
|
-
readonly create: (root: string, input: ThreadInput, author: MessageAuthor) => Effect.Effect<Thread, WorkError>;
|
|
172
|
-
readonly reply: (root: string, id: string, input: ThreadReplyInput, author: MessageAuthor) => Effect.Effect<Thread, WorkError>;
|
|
173
|
-
readonly setStatus: (root: string, id: string, status: ThreadStatus, expectedRevision: string) => Effect.Effect<Thread, WorkError>;
|
|
174
|
-
readonly link: (root: string, id: string, itemIds: string[], expectedRevision: string) => Effect.Effect<Thread, WorkError>;
|
|
175
|
-
readonly unlink: (root: string, id: string, itemIds: string[], expectedRevision: string) => Effect.Effect<Thread, WorkError>;
|
|
176
|
-
readonly sync?: (root: string, direction?: WorkSync["direction"]) => Effect.Effect<ThreadSnapshot, WorkError>;
|
|
177
|
-
/**
|
|
178
|
-
* Deletes one of `author`'s messages; null when it was the first and the discussion is gone.
|
|
179
|
-
* Adapters that implement it report the `delete` capability.
|
|
180
|
-
*/
|
|
181
|
-
readonly deleteMessage?: (root: string, id: string, input: ThreadDeleteInput, author: MessageAuthor) => Effect.Effect<Thread | null, WorkError>;
|
|
182
|
-
/** Signals stored discussion changes, including ones made outside Bud. */
|
|
183
|
-
readonly watch?: (root: string) => Stream.Stream<void, WorkError>;
|
|
184
|
-
}
|
|
185
|
-
declare const ThreadAdapterBase: Context.ServiceClass<ThreadAdapter, "@bud.sh/work/ThreadAdapter", ThreadAdapterOperations>;
|
|
186
|
-
/** Discussions receive trusted server attribution separately from browser input. */
|
|
187
|
-
export declare class ThreadAdapter extends ThreadAdapterBase {}
|
|
188
|
-
//#endregion
|
|
189
|
-
//#region ../work/src/server/memory-state.d.ts
|
|
190
|
-
/** A pure action computes a replacement; the memory adapter validates and commits it. */
|
|
191
|
-
type MemoryAction = (context: {
|
|
192
|
-
item: WorkItem;
|
|
193
|
-
input: WorkPatch;
|
|
194
|
-
schema: WorkSchema;
|
|
195
|
-
author: MessageAuthor;
|
|
196
|
-
}) => {
|
|
197
|
-
values?: WorkPatch;
|
|
198
|
-
relations?: WorkItem["relations"];
|
|
199
|
-
};
|
|
200
|
-
/** The schema, seed records and action and section implementations of an in-memory store. */
|
|
201
|
-
interface MemoryAdapterOptions {
|
|
202
|
-
schema: WorkSchema;
|
|
203
|
-
items?: readonly WorkItem[];
|
|
204
|
-
threads?: readonly Thread[];
|
|
205
|
-
/** Defaults can supply required server-owned fields without making them editable. */
|
|
206
|
-
defaults?: WorkPatch;
|
|
207
|
-
actions?: Readonly<Record<string, MemoryAction>>;
|
|
208
|
-
sections?: Readonly<Record<string, (item: WorkItem) => SectionData>>;
|
|
209
|
-
/** Trusted attribution for work-item history; thread writes supply it separately. */
|
|
210
|
-
author?: MessageAuthor;
|
|
211
|
-
threadCapabilities?: Partial<Omit<ThreadCapabilities, "edit" | "sync">>;
|
|
212
|
-
}
|
|
213
|
-
//#endregion
|
|
214
3
|
//#region ../work/src/server/memory.d.ts
|
|
215
4
|
/**
|
|
216
5
|
* Creates isolated work and discussion services for each layer and project root.
|
|
@@ -219,19 +8,4 @@ interface MemoryAdapterOptions {
|
|
|
219
8
|
*/
|
|
220
9
|
export declare function memoryAdapterLayer(options: MemoryAdapterOptions): Layer.Layer<WorkAdapter | ThreadAdapter, WorkError>;
|
|
221
10
|
//#endregion
|
|
222
|
-
|
|
223
|
-
/** One server module can supply work, threads, or both from the same scoped layer. */
|
|
224
|
-
interface AdapterDefinition {
|
|
225
|
-
id: string;
|
|
226
|
-
label: string;
|
|
227
|
-
work?: Layer.Layer<WorkAdapter, unknown>;
|
|
228
|
-
threads?: Layer.Layer<ThreadAdapter, unknown>;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Defines the services exported by a project-owned .server.ts adapter module.
|
|
232
|
-
* @param definition - The public identity and fully provided Effect layers.
|
|
233
|
-
* @returns The validated definition, without acquiring any services.
|
|
234
|
-
*/
|
|
235
|
-
export declare function defineAdapter(definition: AdapterDefinition): AdapterDefinition;
|
|
236
|
-
//#endregion
|
|
237
|
-
export type { AdapterDefinition, MemoryAdapterOptions, ThreadImportInput, ThreadImportResult, WorkFailureReason, WorkReader };
|
|
11
|
+
export { type MemoryAdapterOptions, ThreadAdapter, type ThreadImportInput, type ThreadImportResult, WorkAdapter, WorkError, type WorkFailureReason, type WorkReader, parseThreadImport };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
//#region src/host/vite.server.d.ts
|
|
3
|
+
/** Options for developing Bud itself against a consumer project. */
|
|
4
|
+
export interface BudPluginOptions {
|
|
5
|
+
/** Use the workspace's Vite UI server so edits to Bud also hot-reload. */
|
|
6
|
+
development?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Hosts Bud's app beside an existing Vite server, whose live updates refresh Bud's page previews.
|
|
10
|
+
* With `BUD_SANDBOX=1`, as in a factory sandbox's dev server, it only serves the page bridge and
|
|
11
|
+
* the picker, for Agent view's browser.
|
|
12
|
+
* @param options - Optional workspace development mode.
|
|
13
|
+
* @returns A development-only Vite plugin with an owned companion lifecycle.
|
|
14
|
+
*/
|
|
15
|
+
export declare function bud(options?: BudPluginOptions): Plugin;
|
|
16
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bud.sh/app",
|
|
3
3
|
"description": "The app, its config, screen and design APIs",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"bud": "./dist/node/cli.js"
|
|
12
|
+
},
|
|
10
13
|
"exports": {
|
|
11
14
|
".": {
|
|
12
15
|
"types": "./dist/types/index.d.ts",
|
|
@@ -20,10 +23,18 @@
|
|
|
20
23
|
"types": "./dist/types/server.d.ts",
|
|
21
24
|
"import": "./dist/node/server.js"
|
|
22
25
|
},
|
|
26
|
+
"./plugins": {
|
|
27
|
+
"types": "./dist/types/plugins.d.ts",
|
|
28
|
+
"import": "./dist/node/plugins.js"
|
|
29
|
+
},
|
|
23
30
|
"./design": {
|
|
24
31
|
"types": "./dist/types/design.d.ts",
|
|
25
32
|
"import": "./dist/node/design.js"
|
|
26
33
|
},
|
|
34
|
+
"./vite": {
|
|
35
|
+
"types": "./dist/types/vite.d.ts",
|
|
36
|
+
"import": "./dist/node/vite.js"
|
|
37
|
+
},
|
|
27
38
|
"./bridge": {
|
|
28
39
|
"types": "./dist/types/bridge.d.ts",
|
|
29
40
|
"import": "./dist/node/bridge.js"
|
|
@@ -55,8 +66,8 @@
|
|
|
55
66
|
},
|
|
56
67
|
"dependencies": {
|
|
57
68
|
"effect": "4.0.5",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
69
|
+
"playwright-core": "1.64.1",
|
|
70
|
+
"remix": "3.0.0"
|
|
60
71
|
},
|
|
61
72
|
"peerDependencies": {
|
|
62
73
|
"vite": ">=8.3.4"
|
|
@@ -70,14 +81,19 @@
|
|
|
70
81
|
"@bud.sh/beads": "0.0.0",
|
|
71
82
|
"@bud.sh/beads-d1": "0.0.0",
|
|
72
83
|
"@bud.sh/comments": "0.0.0",
|
|
84
|
+
"@bud.sh/factory": "0.0.0",
|
|
73
85
|
"@bud.sh/files": "0.0.0",
|
|
74
86
|
"@bud.sh/git": "0.0.0",
|
|
87
|
+
"@bud.sh/harness-opencode": "0.0.0",
|
|
75
88
|
"@bud.sh/live": "0.0.0",
|
|
76
89
|
"@bud.sh/picker": "0.0.0",
|
|
77
90
|
"@bud.sh/picker-react-grab": "0.0.0",
|
|
91
|
+
"@bud.sh/plugin": "0.0.0",
|
|
78
92
|
"@bud.sh/previews": "0.0.0",
|
|
79
93
|
"@bud.sh/project": "0.0.0",
|
|
80
94
|
"@bud.sh/runtime": "0.0.0",
|
|
95
|
+
"@bud.sh/sandbox-boat": "0.0.0",
|
|
96
|
+
"@bud.sh/sandbox-local": "0.0.0",
|
|
81
97
|
"@bud.sh/ui": "0.0.0",
|
|
82
98
|
"@bud.sh/work": "0.0.0",
|
|
83
99
|
"@pierre/diffs": "1.5.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./i18n-hH_Ba5QO.js";import{t}from"./jsx-B4XNFIzB.js";import{t as n}from"./component-DWct-Tq6.js";import{n as r}from"./on-mixin-iWnqUzq5.js";import{n as i}from"./attrs-mixin-CmlG_FtV.js";import{c as a,l as o,t as s}from"./loader-Q6-HPKft.js";import{t as c}from"./screen-Dfvzj6n2.js";import{I as l,T as u,Tt as d,_ as f,v as p,w as m}from"./task-design-BPpc4Gd7.js";import{At as h,G as g,H as _,U as v,jt as y,s as b,st as x}from"./project-threads-ZbKDh78d.js";import{i as S,n as C,t as w}from"./project-comments-D1IIQwsW.js";import{i as T,n as E,t as D}from"./project-branches-CMGRmrqr.js";import{t as O}from"./project-thread-links-DKwe_SYb.js";var k=760,A=r(`pointerdown`,e=>e.stopPropagation());function j(e,t,n){let r=e.capture.width*t,i=e.capture.thumbnails.map(e=>e.width),a=e=>{let t=i.findIndex(t=>r<=t*e);return t<0?`slices`:t},o=e=>e===`slices`?i.length:e,s=a(1);return n===void 0||o(s)>=o(n)||o(a(.85))<o(n)?s:n}function M(e,t){return e?.get(t)??{visible:!0,top:0,bottom:1/0,density:1}}function N(e,t){let n=0;return e.capture.tiles.map((r,i)=>{let a={tile:r,index:i,top:n,src:e.srcs[i]};return n+=r.height,{...a,shownTo:Math.min(n,t)}})}function P(n){let{route:i,previews:c}=n.props,l=i.pageId??i.id,u=()=>T(n.props.theme,n.props.size),f=``,p,m,h=``;function g(e){return n.props.topOnly?e.capture.tiles[0]?.height??e.capture.height:e.capture.height}function _(){let{preview:e,images:t}=c.get(l),r=t[u()]??m,i=r?g(r):e?.captures[0]?.height??(e?.state===`failed`?k:0);if(!e||!i)return;let a=`${i}:${e.path}:${r?.capture.hash??``}`;f!==a&&(f=a,n.props.onLayout({height:i,path:e.path,pins:r?.capture.pins}))}function y(e){let t=M(n.props.viewport,i.id);if(!t.visible||p===void 0)return{thumbnail:void 0,slices:[]};if(p===`slices`&&e.srcs.length){let n=Math.min(t.bottom,g(e));return{thumbnail:e.thumbnails.at(-1),slices:N(e,n).filter(({src:e,top:n,shownTo:r})=>e&&n<r&&r>t.top)}}let r=p===`slices`?e.thumbnails.length-1:p;return{thumbnail:e.thumbnails[r]??e.thumbnails.at(-1),slices:[]}}function b(){let e=c.get(l).images[u()];if(!e||e===m)return;if(!m||m.capture.hash===e.capture.hash){m=e;return}if(p===`slices`&&!e.srcs.length){c.slices(l,n.props.theme,n.props.size);return}let t=`${e.capture.hash}:${p}`;if(h===t)return;h=t;let r=e,{thumbnail:i,slices:a}=y(r);Promise.all([i,...a.map(({src:e})=>e)].flatMap(e=>{if(!e)return[];let t=new Image;return t.src=e,[t.decode().catch(()=>{})]})).then(()=>{h!==t||n.signal.aborted||(h=``,m=c.get(l).images[u()]??r,_(),n.update())})}let x=c.watch(l,()=>{b(),_(),n.update()}),S=n.props.viewport?.watch(i.id,()=>void n.update());return n.signal.addEventListener(`abort`,()=>{x(),S?.()},{once:!0}),()=>{let{mode:u,origin:f,theme:h,viewport:x,size:S}=n.props,{preview:C,images:w,refreshing:E,error:D}=c.get(l);n.queueTask(()=>{c.show(l,h,S),_()});let O=w[T(h,S)]??w[T(h===`dark`?`light`:`dark`,S)];O&&(!m||m.capture.theme!==O.capture.theme)?m=O:b();let k=m,N=D||(C?.captures.length?null:C?.error),P=new URL(i.path,f).href;if(k){let a=M(x,i.id);if(p=j(k,a.density,p),a.visible&&p===`slices`&&!k.srcs.length){let{theme:e}=k.capture;n.queueTask(()=>c.slices(l,e,S))}let o=g(k),{width:s}=k.capture,{thumbnail:d,slices:f}=y(k);return t(`div`,{role:`img`,"aria-label":e(`app.client.previewImage.preview`,{title:i.title}),"data-detail":a.visible?f.length?`slices`:d?`thumbnail`:`pending`:`hidden`,class:`relative select-none overflow-hidden ${u===`comment`?`cursor-crosshair`:``}`,style:{height:o},mix:[r(`pointerdown`,e=>{u!==`pan`&&e.stopPropagation()}),r(`click`,e=>{if(u!==`comment`||C?.path!==i.path)return;e.stopPropagation();let t=e.currentTarget.getBoundingClientRect(),r={x:(e.clientX-t.left)*s/t.width,y:(e.clientY-t.top)*o/t.height};n.props.onPick({element:null,path:i.path,...v(r,s),found:c.describe(l,k.capture,r.x,r.y)})})],children:[d?t(`img`,{src:d,alt:``,decoding:`async`,draggable:!1,class:`absolute inset-x-0 top-0 block w-full max-w-none`,style:{height:k.capture.height}}):null,f.map(({tile:e,index:n,top:r,src:i})=>t(`img`,{src:i,alt:``,decoding:`async`,draggable:!1,class:`absolute inset-x-0 block w-full max-w-none`,style:{top:r,height:e.height+ +(n<k.capture.tiles.length-1)}},e.hash))]})}return C?.state===`failed`||N&&!E?t(`div`,{class:`absolute inset-0 flex flex-col items-center justify-center gap-3 p-12 text-center`,role:`status`,children:[t(d,{name:`circle-alert`,size:24,class:`text-muted`}),t(o,{variant:`title`,weight:`semibold`,class:`text-ink`,children:e(`app.client.previewImage.captureFailed`,{title:i.title})}),N?t(o,{variant:`ui`,class:`max-w-md text-muted`,children:N}):null,t(`div`,{class:`mt-2 flex gap-2`,children:[t(a,{variant:`secondary`,disabled:E,mix:[A,r(`click`,()=>void c.refresh(l))],children:t(o,{variant:`ui`,children:e(`app.client.previewImage.tryAgain`)})}),t(`a`,{href:P,target:`_blank`,rel:`noreferrer`,class:`bud-interaction bud-control flex h-control items-center rounded-lg px-3 text-ink`,mix:A,children:t(o,{variant:`ui`,children:e(`app.client.previewImage.openPage`)})})]})]}):t(`div`,{class:`absolute inset-0 flex items-center justify-center`,children:t(s,{label:e(`app.client.previewImage.capturing`,{title:i.title})})})}}function ee(i){let{route:a,previews:o}=i.props,s=a.pageId??a.id,c=o.watch(s,()=>void i.update());return i.signal.addEventListener(`abort`,c,{once:!0}),()=>{let{preview:i,refreshing:c}=o.get(s),l=c||!!i?.updating,f=i?.state===`ready`?i.error:null;return t(n,{children:[f?t(u,{label:f,children:t(`span`,{tabIndex:0,role:`img`,"aria-label":f,class:`pointer-events-auto ms-1 inline-flex text-amber-500`,mix:A,children:t(d,{name:`circle-alert`,size:13})})}):null,t(m,{icon:`sync`,label:e(`app.client.previewImage.refresh`,{title:a.title}),tooltip:!0,size:`small`,iconSize:13,disabled:c,"aria-busy":l?`true`:void 0,class:`pointer-events-auto ms-0.5 text-muted hover:text-ink ${l?`[&_svg]:animate-spin`:``}`,mix:[A,r(`click`,()=>void o.refresh(s))]})]})}}var F=new Map;function I(){return new Worker(new URL(`/assets/difference-worker-C99ychYw.js`,``+import.meta.url),{type:`module`})}function L(t){let{routes:n,before:r,after:i,theme:a,signal:o}=t,s=new Map,c={get:e=>s.get(e)??{state:`pending`,regions:[]},progress:{compared:0,total:n.length},done:n.length===0},l,u=0,d=new Map;function f(e){l??=I(),l.onmessage=e=>{d.get(e.data.id)?.(e.data),d.delete(e.data.id)};let t=u++;return new Promise(n=>{d.set(t,n),l.postMessage({...e,id:t})})}o.addEventListener(`abort`,()=>l?.terminate(),{once:!0});async function p(e,t){let[n,o]=await Promise.all([r.picture(e,a,t),i.picture(e,a,t)]);if(!n||!o)return{state:`missing`,regions:[],before:n?.capture,after:o?.capture};let s={before:n.capture,after:o.capture};if(n.capture.hash===o.capture.hash)return{state:`same`,regions:[],...s};let c=`${n.capture.hash}\0${o.capture.hash}`,l=F.get(c);if(!l){let e=e=>({images:e.images,heights:e.capture.tiles.map(e=>e.height),scale:e.capture.scale}),t=await f({width:n.capture.width,before:e(n),after:e(o)});if(`error`in t)return{state:`failed`,regions:[],error:t.error,...s};l=t.regions,F.set(c,l)}return{state:l.length?`different`:`same`,regions:l,...s}}return(async()=>{for(let r of n){if(o.aborted)return;let i=await p(r.page,r.size).catch(t=>({state:`failed`,regions:[],error:t instanceof Error?t.message:e(`app.client.projectDifferences.comparisonFailed`)}));if(o.aborted)return;s.set(r.id,i),c.progress={compared:c.progress.compared+1,total:n.length},t.onChange(r.id)}c.done=!0,l?.terminate(),l=void 0,t.onChange(null)})(),c}var R=40,z=48;function B(e){let t=0;return{slots:e.map(e=>{let n={top:t,height:R+Math.max(e.before.height,e.after.height,1)};return t+=n.height+z,n}),height:Math.max(1,t-z)}}function V(t){return e(t===`changed`?`app.client.differenceView.changed`:t===`added`?`app.client.differenceView.added`:`app.client.differenceView.removed`)}function H(e){let t=new Map;return e.addEventListener(`abort`,()=>{for(let e of t.values())URL.revokeObjectURL(e)},{once:!0}),e=>{let n=t.get(e);return n||t.set(e,n=URL.createObjectURL(e)),n}}function te(n){let r=H(n.signal),i=0;return()=>{let{route:a,side:s,label:c,regions:l,viewport:u}=n.props,{slots:d,height:f}=B(l);i!==f&&(i=f,n.queueTask(()=>n.props.onLayout({height:f,path:a.path})));let p=u?.get(a.id)?.visible??!0;return t(`div`,{role:`img`,"aria-label":e(`app.client.differenceView.artboardLabel`,{title:a.title,label:c}),"data-difference":s,"data-changes":l.length,class:`relative select-none bg-[var(--bud-main)]`,style:{height:`${f}px`},children:l.map((n,i)=>{let a=n[s],l=n.crops[s],u=d[i];return t(`div`,{"data-kind":n.kind,"data-span":`${a.y} ${a.height}`,class:`absolute inset-x-0`,style:{top:`${u.top}px`,height:`${u.height}px`},children:[t(`div`,{class:`flex items-center gap-2 px-1`,style:{height:`${R}px`},children:[t(o,{variant:`ui`,weight:`medium`,children:e(`app.client.differenceView.changeNumber`,{count:i+1})}),t(o,{variant:`ui`,tone:`muted`,children:V(n.kind)})]}),l&&a.height>0?t(`div`,{class:`relative overflow-hidden`,style:{height:`${a.height}px`},children:[p?t(`img`,{alt:``,src:r(l),draggable:!1,class:`block h-full w-full`}):null,n.kind===`changed`?t(`div`,{"aria-hidden":`true`,class:`pointer-events-none absolute inset-y-0 rounded-sm outline-2 outline-red-500/70`,style:{left:`${n.x}px`,width:`${Math.max(2,n.width)}px`}}):null]}):t(`div`,{class:`grid h-24 place-items-center rounded-lg border border-dashed border-line`,children:t(o,{variant:`ui`,tone:`muted`,children:e(`app.client.differenceView.notIn`,{label:c})})})]},i)})})}}function ne(n){let a=H(n.signal),s=e=>{let{slides:t,index:r}=n.props;t.length&&n.props.onIndex((r+e+t.length)%t.length)};return()=>{let{slides:c,index:l,beforeLabel:u,afterLabel:d}=n.props,f=c[Math.min(l,c.length-1)],p=(n,r)=>{let i=f?.region.crops[n];return t(`figure`,{class:`m-0 flex min-w-0 flex-col gap-2`,children:[t(`figcaption`,{children:t(o,{variant:`ui`,tone:`muted`,children:r})}),i&&f.region[n].height>0?t(`div`,{class:`relative`,children:[t(`img`,{alt:e(`app.client.differenceView.artboardLabel`,{title:f.route.title,label:r}),src:a(i),class:`block w-full rounded-lg ring-1 ring-line`}),f.region.kind===`changed`?t(`div`,{"aria-hidden":`true`,class:`pointer-events-none absolute inset-y-0 rounded-sm outline-2 outline-red-500/70`,style:{left:`${f.region.x/f.width*100}%`,width:`max(2px, ${f.region.width/f.width*100}%)`}}):null]}):t(`div`,{class:`grid h-32 place-items-center rounded-lg border border-dashed border-line`,children:t(o,{variant:`ui`,tone:`muted`,children:e(`app.client.differenceView.notIn`,{label:r})})})]})};return t(`section`,{role:`dialog`,"aria-label":e(`app.client.differenceView.slideshowLabel`),class:`bud-surface absolute inset-0 z-40 flex flex-col bg-[var(--bud-main)]`,mix:i((e,t)=>{e.focus(),e.ownerDocument.addEventListener(`keydown`,e=>{if(e.key===`ArrowRight`)s(1);else if(e.key===`ArrowLeft`)s(-1);else if(e.key===`Escape`)n.props.onClose();else return;e.preventDefault()},{signal:t})}),tabindex:-1,children:[t(`header`,{class:`flex h-12 shrink-0 items-center gap-2 border-b border-line ps-4 pe-2`,children:[t(`div`,{class:`flex min-w-0 flex-1 items-baseline gap-2`,children:[t(o,{variant:`ui`,weight:`medium`,class:`truncate`,children:f?.route.title??e(`app.client.differenceView.noDifferences`)}),f?t(o,{variant:`ui`,tone:`muted`,class:`shrink-0 tabular-nums`,role:`status`,children:e(`app.client.differenceView.slideStatus`,{kind:V(f.region.kind),change:f.index+1,count:f.count,index:l+1,total:c.length})}):null]}),t(m,{tooltip:!0,icon:`chevron-left`,label:e(`app.client.differenceView.previousChange`),disabled:c.length<2,mix:r(`click`,()=>s(-1))}),t(m,{tooltip:!0,icon:`chevron-right`,label:e(`app.client.differenceView.nextChange`),disabled:c.length<2,mix:r(`click`,()=>s(1))}),t(m,{tooltip:!0,icon:`close`,label:e(`app.client.differenceView.closeSlideshow`),shortcut:`escape`,mix:r(`click`,()=>n.props.onClose())})]}),t(`div`,{class:`min-h-0 flex-1 overflow-auto p-4`,children:f?t(`div`,{class:`grid gap-4 md:grid-cols-2`,children:[p(`before`,u),p(`after`,d)]}):null})]})}}function U(e){return!(!e.anchor||`type`in e.anchor)}function W(e,t){let{themes:n}=e.previews,r=h(t),i=document.documentElement.dataset.theme;return n.find(e=>e===r)??n.find(e=>e===i)??n[0]}function G(i){let a=i.props.project,o,c=w({store:b(a),token:a.token,signal:i.signal,initial:i.props.comments,onChange:()=>{i.update()}});i.props.comments.stored&&c.load();let u=a.workingTree?null:a.main??`main`,d=`bud:canvas-branch:${a.id}`,v=h(d),C=typeof v==`string`?v:u,T=!0,k=!1,A=D({project:a,signal:i.signal,onChange:()=>{C&&C!==u&&A.loaded&&!A.list.branches.some(e=>e.name===C&&e.active)?N(u):i.update()}}),j=new AbortController;i.signal.addEventListener(`abort`,()=>j.abort(),{once:!0});let M=E({project:a,signal:j.signal,branch:C});function N(e){if(k=!1,e===C)return void i.update();C=e,y(d,e),j.abort(),j=new AbortController,M=E({project:a,signal:j.signal,branch:e}),i.update()}let F=`bud:preview-theme:${a.id}`,I=W(a,F),R=`bud:preview-top-only:${a.id}`,z=h(R)===!0,B=a.previews.viewports,V=B.length>1,H=`bud:canvas-viewport:${a.id}`,G=h(H),K=V&&typeof G==`string`&&(G===`all`||B.some(e=>e.id===G))?G:V?`all`:B[0].id;function q(e){e!==K&&(K=e,y(H,e),i.update())}function J(){let e=K===`all`?B:B.filter(e=>e.id===K);return a.routes.flatMap(t=>e.map(e=>({route:t,size:e,artboard:V?{...t,id:`${t.id}@${e.id}`,pageId:t.id,width:e.width,caption:String(e.width)}:t})))}let Y=`bud:canvas-compare:${a.id}`,X=null,Z,Q;function $(){let t=a.workingTree?[{value:``,label:e(`app.client.projectCanvas.workingTree`)}]:[];for(let e of A.list.branches)e.active&&e.captured&&t.push({value:e.name,label:e.name});return t.filter(e=>e.value!==(C??``))}function re(t){return t||e(`app.client.projectCanvas.workingTree`)}function ie(){let e=$(),t=h(Y);X=e.find(e=>e.value===t)?.value??e.find(e=>e.value===(A.list.main??`main`))?.value??e[0]?.value??null,Q=void 0,i.update()}function ae(){X=null,Q=void 0,Z?.controller.abort(),Z=void 0,i.update()}function oe(e){if(X===null||($().some(e=>e.value===X)||(X=$()[0]?.value??null),X===null))return;let t=`${X}\0${C??``}\0${I}\0${K}`;if(Z?.key===t)return Z.result;Z?.controller.abort();let n=new AbortController;i.signal.addEventListener(`abort`,()=>n.abort(),{once:!0});let r=E({project:a,signal:n.signal,branch:X||null}),o=L({routes:J().map(({route:e,size:t,artboard:n})=>({id:n.id,page:e.id,size:t})),before:r,after:e,theme:I,signal:n.signal,onChange:()=>{i.update()}});return Z={key:t,controller:n,result:o},o}function se(e){return!V||K===`all`||(B.find(t=>t.width===e.anchor.viewport)??B[0]).id===K}function ce(e){return e.filter(U).filter(e=>(e.anchor.branch??u)===C).filter(se)}return()=>{if(o!==i.props.threadId){o=i.props.threadId;let e=o;e&&i.queueTask(()=>{c.loadThread(e)})}if(!A.loaded&&!A.error)return t(s,{label:e(`app.client.projectCanvas.loadingBranches`)});let u=`${a.id}:${a.targetOrigin}:${a.routes.map(e=>e.path).join(`|`)}`,d={...c.snapshot,threads:ce(c.snapshot.threads)},h=J(),v=new Map(h.map(({artboard:e,size:t})=>[e.id,t])),b=oe(M),w=re(X),E=re(C),D=b?h.map(({artboard:e})=>e).filter(e=>b.get(e.id).state===`different`):[],j=new Map,L=D.flatMap(e=>[`before`,`after`].map(t=>{let n=`${e.id}#${t}`;return j.set(n,{route:e,side:t}),{id:n,path:e.path,title:e.title,width:e.width,caption:e.caption,compare:{groupId:e.id,groupTitle:e.title,versionLabel:t===`before`?w:E}}})),H=D.flatMap(e=>{let{regions:t,after:n}=b.get(e.id),r=n?.width??e.width??B[0].width;return t.map((n,i)=>({route:e,region:n,index:i,count:t.length,width:r}))}),U=``;if(b){let{compared:t,total:n}=b.progress,r=h.filter(({artboard:e})=>b.get(e.id).state===`missing`).length;U=b.done?D.length?r?e(`app.client.projectCanvas.differentPagesWithMissing`,{changed:D.length,count:n,name:w,missing:r}):e(`app.client.projectCanvas.differentPages`,{changed:D.length,count:n,name:w}):r?e(`app.client.projectCanvas.noDifferencesWithMissing`,{name:w,count:r}):e(`app.client.projectCanvas.noDifferences`,{name:w}):e(`app.client.projectCanvas.comparingPages`,{name:w,done:t,count:n})}let W=$(),G=e=>e.mobile||e.width<600?`mobile`:e.width<1100?`tablet`:`desktop`,se=t(n,{children:[V?t(n,{children:[B.map(n=>t(m,{tooltip:!0,icon:G(n),label:e(`app.client.projectCanvas.showViewport`,{name:n.name,width:n.width}),active:K===n.id,mix:r(`click`,()=>q(n.id))})),t(m,{tooltip:!0,icon:`columns`,label:e(`app.client.projectCanvas.showEveryViewport`),active:K===`all`,mix:r(`click`,()=>q(`all`))}),t(f,{})]}):null,t(m,{tooltip:!0,icon:`compare`,label:e(b?`app.client.projectCanvas.stopComparing`:`app.client.projectCanvas.showDifferences`),active:!!b,disabled:!b&&!W.length,mix:r(`click`,()=>b?ae():ie())}),b?t(n,{children:[t(l,{label:e(`app.client.projectCanvas.compareWith`),value:X??``,options:W,class:`max-w-48`,onChange:e=>{X=e,Q=void 0,y(Y,e),i.update()}}),t(m,{tooltip:!0,icon:`play`,label:e(`app.client.projectCanvas.stepThroughDifferences`),disabled:!H.length,mix:r(`click`,()=>{Q=0,i.update()})})]}):null]});return t(p,{class:`h-full min-h-0`,sidebarLabel:e(`app.client.projectCanvas.branches`),mainLabel:e(`app.client.projectCanvas.canvas`),drawerOpen:k,onDrawerOpenChange:e=>{k=e,i.update()},onWideChange:e=>{T!==e&&(T=e,i.update())},sidebar:t(g,{working:A.list.working,workingTree:a.workingTree,branches:A.list.branches,selected:C,busy:A.busy||!A.loaded,loaded:A.loaded,error:A.error,mobile:!T,onSelect:N,onActivate:(e,t)=>{A.activate(e,t)},onCapture:e=>{A.capture(e)},onClose:()=>{k=!1,i.update()}}),children:t(_,{artboards:b?L:h.map(({artboard:e})=>e),width:B[0].width,storageKey:b?`bud:camera:${u}:differences:${K}`:`bud:camera:${u}:${V?K:B[0].width}`,tools:se,overlay:b&&Q!==void 0?t(ne,{slides:H,index:Q,beforeLabel:w,afterLabel:E,onIndex:e=>{Q=e,i.update()},onClose:()=>{Q=void 0,i.update()}}):null,snapshot:d,capabilities:c.snapshot.capabilities,commentsUnavailable:b?U:(c.loaded?!c.ready:a.storage.threads?.state!==`ready`)?S:void 0,onLoadThread:c.loadThread,renderThreadLinks:e=>t(O,{part:`links`,project:a,thread:e,canLink:c.snapshot.capabilities.link,busy:c.busy,onChange:async()=>{await c.load(),await c.loadThread(e.id,!0)}}),renderThreadActions:e=>t(O,{part:`action`,project:a,thread:e,canLink:c.snapshot.capabilities.link,busy:c.busy,onChange:async()=>{await c.load(),await c.loadThread(e.id,!0)}}),initialThreadId:o,loaded:c.loaded,busy:c.busy,error:c.error,now:c.now,onWrite:async e=>{let t=await c.write(e);return{...t,threads:ce(t.threads)}},onSync:()=>c.sync().catch(()=>{}),onReload:c.load,viewerId:c.viewer?.id,onDeleteComment:(e,t)=>c.remove(e,t),onCopyThreadLink:e=>navigator.clipboard.writeText(new URL(x(e.id),window.location.origin).href),interactive:!1,branch:C,theme:I,onThemeChange:a.previews.themes.length>1?e=>{I=e,y(F,e),i.update()}:void 0,topOnly:z,onTopOnlyChange:b?void 0:e=>{z=e,y(R,e),i.update()},onShowSidebar:T?void 0:()=>{k=!0,i.update()},sidebarLabel:e(`app.client.projectCanvas.branches`),renderArtboard:(e,n)=>{let r=j.get(e.id);return r?t(te,{route:e,side:r.side,label:r.side===`before`?w:E,regions:b.get(r.route.id).regions,...n},`${Z?.key??``}\0${e.id}`):t(P,{route:e,origin:a.targetOrigin,theme:I,size:v.get(e.id)??B[0],topOnly:z,previews:M,...n},`${C??``}\0${e.id}`)},renderArtboardActions:e=>C||b?null:t(ee,{route:e,previews:M})},`${b?`${u}:differences`:u}:${K}`)})}}var K=c({load:({project:e,signal:t})=>C(e,t),render:(e,{project:n,conversation:r})=>t(G,{project:n,comments:e,threadId:r?.id})});export{K as default};
|