@hachej/boring-workspace 0.1.20 → 0.1.23
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/dist/{FileTree-DHVB9rpk.js → FileTree-D8Rmj8Bo.js} +101 -90
- package/dist/{MarkdownEditor-L1KDH0bM.js → MarkdownEditor-DKC4gNT4.js} +1 -1
- package/dist/{WorkspaceLoadingState-DYDxUYnx.js → WorkspaceLoadingState-hKrnYCL3.js} +138 -139
- package/dist/{WorkspaceProvider-CDPaAO5u.js → WorkspaceProvider-Cn0sPgaB.js} +412 -407
- package/dist/app-front.js +2 -2
- package/dist/app-server.d.ts +8 -4
- package/dist/app-server.js +106 -16
- package/dist/{createInMemoryBridge-BDxDzihm.d.ts → createInMemoryBridge-CYNW1h_o.d.ts} +9 -5
- package/dist/server.d.ts +3 -3
- package/dist/server.js +27 -1
- package/dist/shared.d.ts +15 -1
- package/dist/shared.js +16 -1
- package/dist/testing.js +1 -1
- package/dist/{ui-bridge-Gfh1MMgl.d.ts → ui-bridge-CT18yqwN.d.ts} +1 -1
- package/dist/workspace.css +79 -43
- package/dist/workspace.js +5 -5
- package/package.json +5 -3
|
@@ -1,61 +1,71 @@
|
|
|
1
|
-
import { jsx as i, jsxs as
|
|
2
|
-
import { useRef as
|
|
1
|
+
import { jsx as i, jsxs as B } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as T, useEffect as I, useMemo as R, useCallback as x, createContext as C, useContext as _ } from "react";
|
|
3
3
|
import { Tree as q } from "react-arborist";
|
|
4
|
-
import { FolderOpenIcon as z, FolderIcon as
|
|
5
|
-
import { I as
|
|
6
|
-
import { Input as
|
|
4
|
+
import { FolderOpenIcon as z, FolderIcon as S, ChevronRightIcon as J, Loader2Icon as K } from "lucide-react";
|
|
5
|
+
import { I as Q } from "./WorkspaceProvider-Cn0sPgaB.js";
|
|
6
|
+
import { Input as U } from "@hachej/boring-ui-kit";
|
|
7
7
|
import { c as v } from "./utils-B6yFEsav.js";
|
|
8
|
-
|
|
8
|
+
import { createDragDropManager as X } from "dnd-core";
|
|
9
|
+
import { HTML5Backend as Y } from "react-dnd-html5-backend";
|
|
10
|
+
const k = Symbol.for("@hachej/boring-workspace/file-tree-dnd-manager");
|
|
11
|
+
function Z() {
|
|
12
|
+
const r = globalThis;
|
|
13
|
+
return r[k] ?? (r[k] = X(
|
|
14
|
+
Y,
|
|
15
|
+
typeof window > "u" ? void 0 : window
|
|
16
|
+
)), r[k];
|
|
17
|
+
}
|
|
18
|
+
const y = /* @__PURE__ */ new Set(), D = C({
|
|
9
19
|
onContextMenu: void 0,
|
|
10
20
|
editing: null,
|
|
11
|
-
pendingPaths:
|
|
21
|
+
pendingPaths: y,
|
|
12
22
|
onSubmitEdit: void 0,
|
|
13
23
|
onCancelEdit: void 0
|
|
14
24
|
});
|
|
15
|
-
function
|
|
16
|
-
initialValue:
|
|
25
|
+
function $({
|
|
26
|
+
initialValue: r,
|
|
17
27
|
onSubmit: p,
|
|
18
28
|
onCancel: h,
|
|
19
29
|
isDraft: c
|
|
20
30
|
}) {
|
|
21
|
-
const t =
|
|
31
|
+
const t = T(null), u = T(!1);
|
|
22
32
|
I(() => {
|
|
23
33
|
const e = t.current;
|
|
24
34
|
if (e)
|
|
25
|
-
if (e.focus(), !c &&
|
|
26
|
-
const o =
|
|
35
|
+
if (e.focus(), !c && r.includes(".")) {
|
|
36
|
+
const o = r.lastIndexOf(".");
|
|
27
37
|
e.setSelectionRange(0, o);
|
|
28
38
|
} else
|
|
29
39
|
e.select();
|
|
30
|
-
}, [
|
|
31
|
-
const
|
|
40
|
+
}, [r, c]);
|
|
41
|
+
const d = () => {
|
|
32
42
|
var o;
|
|
33
43
|
if (u.current) return;
|
|
34
44
|
u.current = !0;
|
|
35
45
|
const e = ((o = t.current) == null ? void 0 : o.value.trim()) ?? "";
|
|
36
|
-
!e || e ===
|
|
46
|
+
!e || e === r ? h() : p(e);
|
|
37
47
|
};
|
|
38
48
|
return /* @__PURE__ */ i(
|
|
39
|
-
|
|
49
|
+
U,
|
|
40
50
|
{
|
|
41
51
|
ref: t,
|
|
42
52
|
type: "text",
|
|
43
|
-
defaultValue:
|
|
53
|
+
defaultValue: r,
|
|
44
54
|
"data-testid": "file-tree-edit-input",
|
|
45
55
|
"aria-label": c ? "Name" : "Rename",
|
|
46
56
|
onPointerDown: (e) => e.stopPropagation(),
|
|
47
57
|
onClick: (e) => e.stopPropagation(),
|
|
48
58
|
onKeyDown: (e) => {
|
|
49
|
-
e.stopPropagation(), e.key === "Enter" ? (e.preventDefault(),
|
|
59
|
+
e.stopPropagation(), e.key === "Enter" ? (e.preventDefault(), d()) : e.key === "Escape" && (e.preventDefault(), u.current = !0, h());
|
|
50
60
|
},
|
|
51
|
-
onBlur:
|
|
61
|
+
onBlur: d,
|
|
52
62
|
className: "h-5 min-w-0 flex-1 rounded-sm border-[color:var(--accent)]/60 px-1 text-[13px] leading-[1.2] focus-visible:ring-[color:var(--accent)]"
|
|
53
63
|
}
|
|
54
64
|
);
|
|
55
65
|
}
|
|
56
|
-
function
|
|
57
|
-
const { onContextMenu: c, editing: t, pendingPaths: u, onSubmitEdit:
|
|
58
|
-
return /* @__PURE__ */
|
|
66
|
+
function E({ node: r, style: p, dragHandle: h }) {
|
|
67
|
+
const { onContextMenu: c, editing: t, pendingPaths: u, onSubmitEdit: d, onCancelEdit: e } = _(D), o = r.data, f = o.kind === "dir", l = (t == null ? void 0 : t.path) === o.path, g = u.has(o.path), b = f ? r.isOpen ? z : S : Q(o.name || "untitled");
|
|
68
|
+
return /* @__PURE__ */ B(
|
|
59
69
|
"div",
|
|
60
70
|
{
|
|
61
71
|
ref: h,
|
|
@@ -63,23 +73,23 @@ function Q({ node: n, style: p, dragHandle: h }) {
|
|
|
63
73
|
className: v(
|
|
64
74
|
"group relative mx-1 flex items-center gap-1.5 rounded-md px-2 py-0.5 text-[13px] leading-[1.4] cursor-pointer select-none text-foreground",
|
|
65
75
|
"transition-colors duration-150 ease-[cubic-bezier(0.22,1,0.36,1)]",
|
|
66
|
-
!
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
!l && "hover:bg-foreground/[0.04]",
|
|
77
|
+
r.isSelected && !l && "bg-[oklch(from_var(--accent)_l_c_h/0.10)] text-foreground font-medium",
|
|
78
|
+
r.willReceiveDrop && "bg-foreground/5 outline outline-1 outline-border"
|
|
69
79
|
),
|
|
70
80
|
onClick: (s) => {
|
|
71
|
-
|
|
81
|
+
l || (s.stopPropagation(), f ? r.toggle() : (r.select(), r.activate()));
|
|
72
82
|
},
|
|
73
83
|
onContextMenu: (s) => {
|
|
74
|
-
|
|
84
|
+
l || o.isDraft || (s.preventDefault(), s.stopPropagation(), c == null || c(s, o));
|
|
75
85
|
},
|
|
76
86
|
children: [
|
|
77
87
|
f ? /* @__PURE__ */ i(
|
|
78
|
-
|
|
88
|
+
J,
|
|
79
89
|
{
|
|
80
90
|
className: v(
|
|
81
91
|
"h-3 w-3 shrink-0 text-muted-foreground/70 transition-transform duration-150 ease-[cubic-bezier(0.22,1,0.36,1)]",
|
|
82
|
-
|
|
92
|
+
r.isOpen && "rotate-90"
|
|
83
93
|
),
|
|
84
94
|
strokeWidth: 2
|
|
85
95
|
}
|
|
@@ -89,17 +99,17 @@ function Q({ node: n, style: p, dragHandle: h }) {
|
|
|
89
99
|
{
|
|
90
100
|
className: v(
|
|
91
101
|
"h-4 w-4 shrink-0",
|
|
92
|
-
|
|
102
|
+
r.isSelected ? "text-[color:var(--accent)]" : "text-muted-foreground/80"
|
|
93
103
|
),
|
|
94
104
|
strokeWidth: 1.5
|
|
95
105
|
}
|
|
96
106
|
),
|
|
97
|
-
|
|
98
|
-
|
|
107
|
+
l ? /* @__PURE__ */ i(
|
|
108
|
+
$,
|
|
99
109
|
{
|
|
100
110
|
initialValue: (t == null ? void 0 : t.initialValue) ?? o.name ?? "",
|
|
101
111
|
isDraft: !!(t != null && t.isDraft),
|
|
102
|
-
onSubmit: (s) =>
|
|
112
|
+
onSubmit: (s) => d == null ? void 0 : d(o.path, s),
|
|
103
113
|
onCancel: () => e == null ? void 0 : e()
|
|
104
114
|
}
|
|
105
115
|
) : /* @__PURE__ */ i(
|
|
@@ -107,12 +117,12 @@ function Q({ node: n, style: p, dragHandle: h }) {
|
|
|
107
117
|
{
|
|
108
118
|
className: v(
|
|
109
119
|
"truncate",
|
|
110
|
-
|
|
120
|
+
g && "text-muted-foreground italic"
|
|
111
121
|
),
|
|
112
122
|
children: o.name
|
|
113
123
|
}
|
|
114
124
|
),
|
|
115
|
-
|
|
125
|
+
g && !l && /* @__PURE__ */ i(
|
|
116
126
|
K,
|
|
117
127
|
{
|
|
118
128
|
"data-testid": "file-tree-pending-spinner",
|
|
@@ -125,102 +135,102 @@ function Q({ node: n, style: p, dragHandle: h }) {
|
|
|
125
135
|
}
|
|
126
136
|
);
|
|
127
137
|
}
|
|
128
|
-
function
|
|
129
|
-
files:
|
|
138
|
+
function ie({
|
|
139
|
+
files: r,
|
|
130
140
|
selectedPath: p,
|
|
131
141
|
searchQuery: h,
|
|
132
142
|
height: c = 400,
|
|
133
143
|
editing: t,
|
|
134
144
|
revealPath: u,
|
|
135
|
-
pendingPaths:
|
|
145
|
+
pendingPaths: d,
|
|
136
146
|
onSelect: e,
|
|
137
147
|
onExpand: o,
|
|
138
148
|
onCollapse: f,
|
|
139
|
-
onContextMenu:
|
|
140
|
-
onSubmitEdit:
|
|
149
|
+
onContextMenu: l,
|
|
150
|
+
onSubmitEdit: g,
|
|
141
151
|
onCancelEdit: b,
|
|
142
152
|
onDragDrop: s,
|
|
143
|
-
className:
|
|
153
|
+
className: P
|
|
144
154
|
}) {
|
|
145
|
-
const
|
|
155
|
+
const N = T(null);
|
|
146
156
|
I(() => {
|
|
147
157
|
if (!(t != null && t.isDraft)) return;
|
|
148
|
-
const
|
|
158
|
+
const n = requestAnimationFrame(() => {
|
|
149
159
|
var a;
|
|
150
|
-
(a =
|
|
160
|
+
(a = N.current) == null || a.scrollTo(t.path);
|
|
151
161
|
});
|
|
152
|
-
return () => cancelAnimationFrame(
|
|
162
|
+
return () => cancelAnimationFrame(n);
|
|
153
163
|
}, [t == null ? void 0 : t.isDraft, t == null ? void 0 : t.path]), I(() => {
|
|
154
164
|
if (!u) return;
|
|
155
|
-
const
|
|
165
|
+
const n = requestAnimationFrame(() => {
|
|
156
166
|
var a;
|
|
157
|
-
(a =
|
|
167
|
+
(a = N.current) == null || a.scrollTo(u);
|
|
158
168
|
});
|
|
159
|
-
return () => cancelAnimationFrame(
|
|
160
|
-
}, [
|
|
161
|
-
const
|
|
169
|
+
return () => cancelAnimationFrame(n);
|
|
170
|
+
}, [r, u]);
|
|
171
|
+
const F = R(
|
|
162
172
|
() => p || void 0,
|
|
163
173
|
[p]
|
|
164
|
-
),
|
|
165
|
-
(
|
|
166
|
-
|
|
174
|
+
), M = x(
|
|
175
|
+
(n) => {
|
|
176
|
+
n.data.kind === "file" && (e == null || e(n.data.path));
|
|
167
177
|
},
|
|
168
178
|
[e]
|
|
169
|
-
),
|
|
170
|
-
(
|
|
179
|
+
), A = x(
|
|
180
|
+
(n) => {
|
|
171
181
|
var m;
|
|
172
|
-
const a = (m =
|
|
182
|
+
const a = (m = N.current) == null ? void 0 : m.get(n);
|
|
173
183
|
a && (a.isOpen ? o == null || o(a.data.path) : f == null || f(a.data.path));
|
|
174
184
|
},
|
|
175
185
|
[o, f]
|
|
176
|
-
),
|
|
177
|
-
(
|
|
186
|
+
), O = x(
|
|
187
|
+
(n) => {
|
|
178
188
|
if (!s) return;
|
|
179
|
-
const a = !
|
|
180
|
-
if (!(!a &&
|
|
181
|
-
for (const
|
|
182
|
-
const
|
|
183
|
-
if (m ===
|
|
184
|
-
s(
|
|
189
|
+
const a = !n.parentNode || n.parentNode.isRoot, m = a ? "." : n.parentNode.data.path;
|
|
190
|
+
if (!(!a && n.parentNode.data.kind !== "dir"))
|
|
191
|
+
for (const L of n.dragNodes) {
|
|
192
|
+
const w = L.data.path;
|
|
193
|
+
if (m === w || m !== "." && m.startsWith(w + "/")) return;
|
|
194
|
+
s(w, m);
|
|
185
195
|
}
|
|
186
196
|
},
|
|
187
197
|
[s]
|
|
188
|
-
),
|
|
189
|
-
(
|
|
190
|
-
if (!
|
|
191
|
-
if (
|
|
192
|
-
for (const a of
|
|
193
|
-
if (
|
|
198
|
+
), W = x(
|
|
199
|
+
(n) => {
|
|
200
|
+
if (!n.parentNode || n.parentNode.isRoot) return !1;
|
|
201
|
+
if (n.parentNode.data.kind !== "dir") return !0;
|
|
202
|
+
for (const a of n.dragNodes)
|
|
203
|
+
if (n.parentNode.data.path === a.data.path || n.parentNode.data.path.startsWith(a.data.path + "/")) return !0;
|
|
194
204
|
return !1;
|
|
195
205
|
},
|
|
196
206
|
[]
|
|
197
|
-
),
|
|
198
|
-
(
|
|
207
|
+
), j = x(
|
|
208
|
+
(n, a) => n.data.name.toLowerCase().includes(a.toLowerCase()),
|
|
199
209
|
[]
|
|
200
|
-
),
|
|
210
|
+
), H = R(
|
|
201
211
|
() => ({
|
|
202
|
-
onContextMenu:
|
|
212
|
+
onContextMenu: l,
|
|
203
213
|
editing: t ?? null,
|
|
204
|
-
pendingPaths:
|
|
205
|
-
onSubmitEdit:
|
|
214
|
+
pendingPaths: d ?? y,
|
|
215
|
+
onSubmitEdit: g,
|
|
206
216
|
onCancelEdit: b
|
|
207
217
|
}),
|
|
208
|
-
[
|
|
218
|
+
[l, t, d, g, b]
|
|
209
219
|
);
|
|
210
|
-
return
|
|
220
|
+
return r.length === 0 ? /* @__PURE__ */ i(
|
|
211
221
|
"div",
|
|
212
222
|
{
|
|
213
223
|
className: v(
|
|
214
224
|
"flex h-full items-center justify-center text-sm text-muted-foreground",
|
|
215
|
-
|
|
225
|
+
P
|
|
216
226
|
),
|
|
217
227
|
children: "No files"
|
|
218
228
|
}
|
|
219
|
-
) : /* @__PURE__ */ i(
|
|
229
|
+
) : /* @__PURE__ */ i(D.Provider, { value: H, children: /* @__PURE__ */ i("div", { "data-boring-workspace-part": "file-tree", className: v("file-tree", P), children: /* @__PURE__ */ i(
|
|
220
230
|
q,
|
|
221
231
|
{
|
|
222
|
-
ref:
|
|
223
|
-
data:
|
|
232
|
+
ref: N,
|
|
233
|
+
data: r,
|
|
224
234
|
idAccessor: "path",
|
|
225
235
|
childrenAccessor: "children",
|
|
226
236
|
openByDefault: !1,
|
|
@@ -228,18 +238,19 @@ function te({
|
|
|
228
238
|
height: c,
|
|
229
239
|
rowHeight: 26,
|
|
230
240
|
indent: 14,
|
|
231
|
-
selection:
|
|
241
|
+
selection: F,
|
|
232
242
|
searchTerm: h ?? "",
|
|
233
|
-
searchMatch:
|
|
234
|
-
onActivate:
|
|
235
|
-
onToggle:
|
|
236
|
-
onMove:
|
|
237
|
-
disableDrop:
|
|
243
|
+
searchMatch: j,
|
|
244
|
+
onActivate: M,
|
|
245
|
+
onToggle: A,
|
|
246
|
+
onMove: O,
|
|
247
|
+
disableDrop: W,
|
|
238
248
|
disableEdit: !0,
|
|
239
|
-
|
|
249
|
+
dndManager: Z(),
|
|
250
|
+
children: E
|
|
240
251
|
}
|
|
241
252
|
) }) });
|
|
242
253
|
}
|
|
243
254
|
export {
|
|
244
|
-
|
|
255
|
+
ie as FileTree
|
|
245
256
|
};
|
|
@@ -15,7 +15,7 @@ import { TableHeader as ut } from "@tiptap/extension-table-header";
|
|
|
15
15
|
import { TableCell as gt } from "@tiptap/extension-table-cell";
|
|
16
16
|
import dt from "@tiptap/extension-image";
|
|
17
17
|
import { c as U } from "./utils-B6yFEsav.js";
|
|
18
|
-
import { ao as q, ap as _ } from "./WorkspaceProvider-
|
|
18
|
+
import { ao as q, ap as _ } from "./WorkspaceProvider-Cn0sPgaB.js";
|
|
19
19
|
import { uploadFile as ft } from "@hachej/boring-agent/front";
|
|
20
20
|
import mt from "@tiptap/extension-code-block-lowlight";
|
|
21
21
|
import { createLowlight as pt, common as ht } from "lowlight";
|