@pstdio/workbench 0.11.4 → 0.12.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/dist/extensions.d.ts +15 -0
- package/dist/extensions.js +651 -641
- package/dist/extensions.js.map +1 -1
- package/dist/file-renderer-view-BJ3LX04R.js +545 -0
- package/dist/file-renderer-view-BJ3LX04R.js.map +1 -0
- package/dist/index-DwNKY4fO.js +5286 -0
- package/dist/index-DwNKY4fO.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1714 -1617
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +7 -4
- package/dist/react.js +51 -5266
- package/dist/react.js.map +1 -1
- package/dist/webview-runtime.js +1 -1
- package/dist/webview-runtime.js.map +1 -1
- package/dist/{workbench-renderers-BhgHQ-Ne.js → workbench-renderers-BAPxtfpZ.js} +263 -257
- package/dist/workbench-renderers-BAPxtfpZ.js.map +1 -0
- package/dist/{workspaces-B9HZHIbz.js → workspaces-DdUPyzkL.js} +350 -339
- package/dist/workspaces-DdUPyzkL.js.map +1 -0
- package/package.json +3 -3
- package/dist/file-renderer-view-Bfmw6RxV.js +0 -515
- package/dist/file-renderer-view-Bfmw6RxV.js.map +0 -1
- package/dist/workbench-renderers-BhgHQ-Ne.js.map +0 -1
- package/dist/workspaces-B9HZHIbz.js.map +0 -1
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
import { jsx as h, jsxs as H } from "react/jsx-runtime";
|
|
2
|
+
import { c as le } from "react/compiler-runtime";
|
|
3
|
+
import { Image as ke, Box as ge, Flex as V, Center as oe, Text as se, Button as Se, Spinner as Fe } from "@chakra-ui/react";
|
|
4
|
+
import { resourceKey as q } from "@pstdio/sdk/extensions";
|
|
5
|
+
import { useState as me, useRef as D, useEffect as ie, useLayoutEffect as Ke } from "react";
|
|
6
|
+
import { EmptyState as je, useFileIconThemePreference as Te, resolveFileIconElement as Le, Header as Ae } from "@pstdio/ui";
|
|
7
|
+
import { CodeEditor as He } from "@pstdio/ui/diff";
|
|
8
|
+
import { MarkdownEditor as Oe } from "@pstdio/ui/rich-text";
|
|
9
|
+
import { r as Ie, a as Pe, s as $e } from "./index-DwNKY4fO.js";
|
|
10
|
+
import { a0 as F } from "./workbench-renderers-BAPxtfpZ.js";
|
|
11
|
+
const Be = "pstdio.fileSectionNavigation", De = (r) => {
|
|
12
|
+
if (!r || typeof r != "object") return !1;
|
|
13
|
+
const e = r, t = e.occurrence === void 0 || typeof e.occurrence == "number" && Number.isInteger(e.occurrence) && e.occurrence >= 0;
|
|
14
|
+
return typeof e.id == "string" && typeof e.heading == "string" && t;
|
|
15
|
+
}, qe = (r) => {
|
|
16
|
+
const e = r?.metadata?.[Be];
|
|
17
|
+
if (!e || typeof e != "object") return;
|
|
18
|
+
const t = e;
|
|
19
|
+
if (!(typeof t.treeId != "string" || typeof t.targetNodeId != "string") && !(!Array.isArray(t.anchors) || !t.anchors.every(De)))
|
|
20
|
+
return {
|
|
21
|
+
treeId: t.treeId,
|
|
22
|
+
targetNodeId: t.targetNodeId,
|
|
23
|
+
anchors: t.anchors
|
|
24
|
+
};
|
|
25
|
+
}, Ve = (r, e) => e && r.anchors.some((t) => t.id === e) ? e : r.targetNodeId, We = (r) => {
|
|
26
|
+
const {
|
|
27
|
+
previous: e,
|
|
28
|
+
current: t,
|
|
29
|
+
currentResourceKey: l,
|
|
30
|
+
selectedNodeId: n
|
|
31
|
+
} = r;
|
|
32
|
+
return !e || !n || !e.anchorIds.includes(n) || t?.targetNodeId === n ? !1 : !t || e.treeId !== t.treeId || e.resourceKey !== l;
|
|
33
|
+
}, Me = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "gif", "webp", "svg", "avif", "bmp", "ico"]), Ue = /* @__PURE__ */ new Set(["md", "markdown", "txt"]), Ee = {
|
|
34
|
+
ts: "typescript",
|
|
35
|
+
tsx: "typescript",
|
|
36
|
+
js: "javascript",
|
|
37
|
+
jsx: "javascript",
|
|
38
|
+
mjs: "javascript",
|
|
39
|
+
cjs: "javascript",
|
|
40
|
+
json: "json",
|
|
41
|
+
jsonc: "json",
|
|
42
|
+
py: "python",
|
|
43
|
+
rb: "ruby",
|
|
44
|
+
rs: "rust",
|
|
45
|
+
go: "go",
|
|
46
|
+
java: "java",
|
|
47
|
+
kt: "kotlin",
|
|
48
|
+
c: "c",
|
|
49
|
+
h: "c",
|
|
50
|
+
cpp: "cpp",
|
|
51
|
+
cc: "cpp",
|
|
52
|
+
hpp: "cpp",
|
|
53
|
+
cs: "csharp",
|
|
54
|
+
php: "php",
|
|
55
|
+
swift: "swift",
|
|
56
|
+
sh: "shell",
|
|
57
|
+
bash: "shell",
|
|
58
|
+
zsh: "shell",
|
|
59
|
+
sql: "sql",
|
|
60
|
+
css: "css",
|
|
61
|
+
scss: "scss",
|
|
62
|
+
less: "less",
|
|
63
|
+
html: "html",
|
|
64
|
+
xml: "xml",
|
|
65
|
+
yml: "yaml",
|
|
66
|
+
yaml: "yaml",
|
|
67
|
+
toml: "ini",
|
|
68
|
+
ini: "ini",
|
|
69
|
+
dockerfile: "dockerfile",
|
|
70
|
+
graphql: "graphql",
|
|
71
|
+
gql: "graphql",
|
|
72
|
+
md: "markdown",
|
|
73
|
+
markdown: "markdown",
|
|
74
|
+
txt: "plaintext"
|
|
75
|
+
}, pe = (r) => {
|
|
76
|
+
if (!r) return "";
|
|
77
|
+
const e = r.lastIndexOf(".");
|
|
78
|
+
return e < 0 || e === r.length - 1 ? "" : r.slice(e + 1).toLowerCase();
|
|
79
|
+
}, Ye = (r, e) => e?.startsWith("image/") ? !0 : Me.has(pe(r)), ze = (r, e) => {
|
|
80
|
+
if (Ye(r, e)) return "image";
|
|
81
|
+
const t = pe(r);
|
|
82
|
+
return !Ue.has(t) && t in Ee ? "code" : "markdown";
|
|
83
|
+
}, Ge = (r) => Ee[pe(r)] ?? "plaintext", Xe = (r, e) => {
|
|
84
|
+
if (r.emptyState) return {
|
|
85
|
+
kind: "empty",
|
|
86
|
+
isEditable: !1
|
|
87
|
+
};
|
|
88
|
+
const t = ze(r.fileName, r.mimeType);
|
|
89
|
+
if (t === "image") return {
|
|
90
|
+
kind: "image",
|
|
91
|
+
isEditable: !1
|
|
92
|
+
};
|
|
93
|
+
const l = e && r.editable !== !1;
|
|
94
|
+
return t === "code" || r.textRenderer === "monaco" ? {
|
|
95
|
+
kind: "code",
|
|
96
|
+
isEditable: l,
|
|
97
|
+
language: Ge(r.fileName)
|
|
98
|
+
} : {
|
|
99
|
+
kind: "markdown",
|
|
100
|
+
isEditable: l
|
|
101
|
+
};
|
|
102
|
+
}, Je = (r) => {
|
|
103
|
+
const e = le(41), {
|
|
104
|
+
content: t,
|
|
105
|
+
editorKey: l,
|
|
106
|
+
errorNotice: n,
|
|
107
|
+
contributionCanSave: i,
|
|
108
|
+
onActiveSectionChange: c,
|
|
109
|
+
onChange: y,
|
|
110
|
+
rendererRef: p,
|
|
111
|
+
sectionNavigation: d,
|
|
112
|
+
title: T
|
|
113
|
+
} = r;
|
|
114
|
+
let k;
|
|
115
|
+
e[0] !== t || e[1] !== i ? (k = Xe(t, i), e[0] = t, e[1] = i, e[2] = k) : k = e[2];
|
|
116
|
+
const f = k;
|
|
117
|
+
if (f.kind === "empty") {
|
|
118
|
+
const S = t.emptyState?.title ?? "Select a file", v = t.emptyState?.description;
|
|
119
|
+
let a;
|
|
120
|
+
e[3] !== S || e[4] !== v ? (a = /* @__PURE__ */ h(je, { flex: "1", minH: "0", title: S, description: v }), e[3] = S, e[4] = v, e[5] = a) : a = e[5];
|
|
121
|
+
let b;
|
|
122
|
+
return e[6] !== n || e[7] !== a ? (b = /* @__PURE__ */ H(V, { direction: "column", h: "full", minH: "0", bg: "bg", children: [
|
|
123
|
+
n,
|
|
124
|
+
a
|
|
125
|
+
] }), e[6] = n, e[7] = a, e[8] = b) : b = e[8], b;
|
|
126
|
+
}
|
|
127
|
+
if (f.kind === "image") {
|
|
128
|
+
if (!t.dataUrl) {
|
|
129
|
+
let x;
|
|
130
|
+
return e[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (x = /* @__PURE__ */ h(oe, { h: "full", minH: "0", bg: "bg", p: "md", children: /* @__PURE__ */ h(se, { color: "fg.muted", children: "This image preview is unavailable." }) }), e[9] = x) : x = e[9], x;
|
|
131
|
+
}
|
|
132
|
+
const S = t.fileName ?? T;
|
|
133
|
+
let v;
|
|
134
|
+
e[10] !== t.dataUrl || e[11] !== S ? (v = /* @__PURE__ */ h(ke, { src: t.dataUrl, alt: S, maxW: "100%", maxH: "100%", objectFit: "contain" }), e[10] = t.dataUrl, e[11] = S, e[12] = v) : v = e[12];
|
|
135
|
+
let a;
|
|
136
|
+
e[13] !== p || e[14] !== v ? (a = /* @__PURE__ */ h(oe, { ref: p, flex: "1", minH: "0", p: "md", overflow: "auto", children: v }), e[13] = p, e[14] = v, e[15] = a) : a = e[15];
|
|
137
|
+
let b;
|
|
138
|
+
return e[16] !== n || e[17] !== a ? (b = /* @__PURE__ */ H(V, { direction: "column", h: "full", minH: "0", bg: "bg", children: [
|
|
139
|
+
n,
|
|
140
|
+
a
|
|
141
|
+
] }), e[16] = n, e[17] = a, e[18] = b) : b = e[18], b;
|
|
142
|
+
}
|
|
143
|
+
if (f.kind === "code") {
|
|
144
|
+
const S = t.content ?? "", v = f.isEditable ? y : void 0;
|
|
145
|
+
let a;
|
|
146
|
+
e[19] !== t.fileName || e[20] !== l || e[21] !== f.isEditable || e[22] !== f.language || e[23] !== S || e[24] !== v ? (a = /* @__PURE__ */ h(ge, { flex: "1", minH: "0", children: /* @__PURE__ */ h(He, { language: f.language, fileName: t.fileName, defaultCode: S, isEditable: f.isEditable, showLineNumbers: !0, onChange: v }, l) }), e[19] = t.fileName, e[20] = l, e[21] = f.isEditable, e[22] = f.language, e[23] = S, e[24] = v, e[25] = a) : a = e[25];
|
|
147
|
+
let b;
|
|
148
|
+
return e[26] !== n || e[27] !== a ? (b = /* @__PURE__ */ H(V, { direction: "column", h: "full", minH: "0", bg: "bg", children: [
|
|
149
|
+
n,
|
|
150
|
+
a
|
|
151
|
+
] }), e[26] = n, e[27] = a, e[28] = b) : b = e[28], b;
|
|
152
|
+
}
|
|
153
|
+
const K = t.content ?? "", _ = f.isEditable ? t.placeholder ?? "Write…" : void 0, g = f.isEditable ? y : void 0;
|
|
154
|
+
let N;
|
|
155
|
+
e[29] !== l || e[30] !== c || e[31] !== f.isEditable || e[32] !== d || e[33] !== K || e[34] !== _ || e[35] !== g ? (N = /* @__PURE__ */ h(ge, { flex: "1", minH: "0", overflowY: "auto", children: /* @__PURE__ */ h(Oe, { defaultState: K, isEditable: f.isEditable, sectionNavigation: d, placeholder: _, onActiveSectionChange: c, onChange: g }, l) }), e[29] = l, e[30] = c, e[31] = f.isEditable, e[32] = d, e[33] = K, e[34] = _, e[35] = g, e[36] = N) : N = e[36];
|
|
156
|
+
let I;
|
|
157
|
+
return e[37] !== n || e[38] !== p || e[39] !== N ? (I = /* @__PURE__ */ H(V, { ref: p, direction: "column", h: "full", minH: "0", overflow: "hidden", bg: "bg", children: [
|
|
158
|
+
n,
|
|
159
|
+
N
|
|
160
|
+
] }), e[37] = n, e[38] = p, e[39] = N, e[40] = I) : I = e[40], I;
|
|
161
|
+
}, Qe = (r) => {
|
|
162
|
+
let e, t = !1, l, n = null, i = null, c, y, p = !1, d = null, T = 0;
|
|
163
|
+
const k = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), K = (s) => s instanceof Error ? s.message : "Failed to save file.", _ = () => ({
|
|
164
|
+
dirty: n !== null || i !== null && i.value !== e,
|
|
165
|
+
saving: i !== null,
|
|
166
|
+
...c ? {
|
|
167
|
+
saveError: c
|
|
168
|
+
} : {},
|
|
169
|
+
...t ? {
|
|
170
|
+
removed: !0
|
|
171
|
+
} : {}
|
|
172
|
+
}), g = () => r.onStateChange?.(_()), N = () => {
|
|
173
|
+
d !== null && (clearTimeout(d), d = null);
|
|
174
|
+
}, I = () => r.createOperationId?.() ?? `file-save-${Date.now()}-${++T}`, S = () => n !== null || i !== null || d !== null || !!c, v = (s) => {
|
|
175
|
+
s.revision && (!y || s.revision.localeCompare(y) > 0) && (y = s.revision), s.revision || (p = !0);
|
|
176
|
+
}, a = (s) => {
|
|
177
|
+
const u = s.origin?.operationId;
|
|
178
|
+
return !u || s.origin?.rendererId !== r.binding.rendererId || s.origin.instanceId !== r.binding.instanceId ? !1 : i?.origin.operationId === u || f.has(u);
|
|
179
|
+
}, b = (s) => {
|
|
180
|
+
if (n !== null || i) return;
|
|
181
|
+
const u = y, R = p;
|
|
182
|
+
if (y = void 0, p = !1, u && (!s || u.localeCompare(s) > 0)) {
|
|
183
|
+
r.load({
|
|
184
|
+
resourceKey: r.binding.resourceKey,
|
|
185
|
+
revision: u
|
|
186
|
+
});
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
R && r.load({
|
|
190
|
+
resourceKey: r.binding.resourceKey
|
|
191
|
+
});
|
|
192
|
+
}, x = () => {
|
|
193
|
+
if (t || n === null || i || c) return;
|
|
194
|
+
const s = n;
|
|
195
|
+
n = null;
|
|
196
|
+
const u = {
|
|
197
|
+
rendererId: r.binding.rendererId,
|
|
198
|
+
instanceId: r.binding.instanceId,
|
|
199
|
+
operationId: I()
|
|
200
|
+
};
|
|
201
|
+
i = {
|
|
202
|
+
value: s,
|
|
203
|
+
origin: u
|
|
204
|
+
}, g(), Promise.resolve(r.save(s, u)).then((R) => {
|
|
205
|
+
if (i?.origin.operationId === u.operationId) {
|
|
206
|
+
if (i = null, f.add(u.operationId), f.size > 20 && f.delete(f.values().next().value), e = s, l = R?.revision ?? l, n === e && (n = null, N()), g(), n !== null) {
|
|
207
|
+
L();
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
b(R?.revision);
|
|
211
|
+
}
|
|
212
|
+
}).catch((R) => {
|
|
213
|
+
t || i?.origin.operationId === u.operationId && (i = null, n === null && (n = s), c = K(R), g());
|
|
214
|
+
});
|
|
215
|
+
}, L = () => {
|
|
216
|
+
N(), d = setTimeout(() => {
|
|
217
|
+
d = null, x();
|
|
218
|
+
}, r.debounceMs);
|
|
219
|
+
};
|
|
220
|
+
return {
|
|
221
|
+
getDraft() {
|
|
222
|
+
return n ?? i?.value ?? e;
|
|
223
|
+
},
|
|
224
|
+
markRemoved() {
|
|
225
|
+
const s = S();
|
|
226
|
+
return t = !0, n = n ?? i?.value ?? null, i = null, N(), g(), s;
|
|
227
|
+
},
|
|
228
|
+
getBaseline() {
|
|
229
|
+
return e;
|
|
230
|
+
},
|
|
231
|
+
getState: _,
|
|
232
|
+
setBaseline(s, u) {
|
|
233
|
+
e = s, l = u, g();
|
|
234
|
+
},
|
|
235
|
+
// Takes a freshly loaded value as the new baseline and returns the value the
|
|
236
|
+
// editor was showing, so the caller can tell whether the editor must show
|
|
237
|
+
// something else. Returns null while pending local state must keep the
|
|
238
|
+
// editor: the refresh is deferred until the save settles.
|
|
239
|
+
acceptLoaded(s, u) {
|
|
240
|
+
if (t) return null;
|
|
241
|
+
if (S())
|
|
242
|
+
return v(u ? {
|
|
243
|
+
revision: u
|
|
244
|
+
} : {}), null;
|
|
245
|
+
const R = e;
|
|
246
|
+
return e = s, l = u, g(), {
|
|
247
|
+
shown: R
|
|
248
|
+
};
|
|
249
|
+
},
|
|
250
|
+
handleChange(s) {
|
|
251
|
+
if (t) {
|
|
252
|
+
n = s, g();
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (!(c && s === n)) {
|
|
256
|
+
if (c = void 0, s === e && !i) {
|
|
257
|
+
n = null, N(), g();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
if (i?.value === s) {
|
|
261
|
+
n = null, N(), g();
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
n = s, L(), g();
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
handleRefreshEvent(s = {}) {
|
|
268
|
+
if (!t && !(s.resourceKey && s.resourceKey !== r.binding.resourceKey) && !a(s) && !(s.revision && k.has(s.revision))) {
|
|
269
|
+
if (s.revision && k.add(s.revision), S()) {
|
|
270
|
+
v(s);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
s.revision && l && s.revision.localeCompare(l) <= 0 || r.load(s);
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
retry() {
|
|
277
|
+
!c || n === null || i || (c = void 0, g(), x());
|
|
278
|
+
},
|
|
279
|
+
retryLoad() {
|
|
280
|
+
t || r.load({
|
|
281
|
+
resourceKey: r.binding.resourceKey
|
|
282
|
+
});
|
|
283
|
+
},
|
|
284
|
+
flush() {
|
|
285
|
+
N(), x();
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}, he = (r) => {
|
|
289
|
+
const e = le(7), {
|
|
290
|
+
message: t,
|
|
291
|
+
onRetry: l
|
|
292
|
+
} = r;
|
|
293
|
+
let n;
|
|
294
|
+
e[0] !== t ? (n = /* @__PURE__ */ h(se, { color: "fg.muted", textStyle: "label/S/regular", children: t }), e[0] = t, e[1] = n) : n = e[1];
|
|
295
|
+
let i;
|
|
296
|
+
e[2] !== l ? (i = l ? /* @__PURE__ */ h(Se, { size: "2xs", variant: "subtle", onClick: l, children: "Retry" }) : null, e[2] = l, e[3] = i) : i = e[3];
|
|
297
|
+
let c;
|
|
298
|
+
return e[4] !== n || e[5] !== i ? (c = /* @__PURE__ */ H(V, { flex: "none", alignItems: "center", justifyContent: "space-between", gap: "sm", borderBottomWidth: "1px", borderColor: "border.muted", bg: "bg.muted", px: "sm", py: "xs", children: [
|
|
299
|
+
n,
|
|
300
|
+
i
|
|
301
|
+
] }), e[4] = n, e[5] = i, e[6] = c) : c = e[6], c;
|
|
302
|
+
}, be = (r) => Array.isArray(r) ? r.map(be) : !r || typeof r != "object" ? r : Object.fromEntries(Object.entries(r).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => [e, be(t)])), Ze = (r) => {
|
|
303
|
+
const {
|
|
304
|
+
fileRendererId: e,
|
|
305
|
+
resource: t
|
|
306
|
+
} = r, l = t ? be({
|
|
307
|
+
id: t.id,
|
|
308
|
+
type: t.type,
|
|
309
|
+
metadata: t.metadata
|
|
310
|
+
}) : null;
|
|
311
|
+
return `${JSON.stringify(q(t))}:${e}:${JSON.stringify(l)}`;
|
|
312
|
+
}, et = (r, e) => r?.loadKey === e, tt = (r) => {
|
|
313
|
+
const e = le(9), {
|
|
314
|
+
fileName: t,
|
|
315
|
+
filePath: l
|
|
316
|
+
} = r, {
|
|
317
|
+
activeFileIconTheme: n
|
|
318
|
+
} = Te();
|
|
319
|
+
let i;
|
|
320
|
+
e[0] !== n || e[1] !== t ? (i = Le(t, {
|
|
321
|
+
theme: n
|
|
322
|
+
}), e[0] = n, e[1] = t, e[2] = i) : i = e[2];
|
|
323
|
+
const c = `File path ${l}`;
|
|
324
|
+
let y;
|
|
325
|
+
e[3] !== l || e[4] !== c ? (y = /* @__PURE__ */ h(se, { "aria-label": c, textStyle: "label/S/regular", color: "fg.muted", truncate: !0, children: l }), e[3] = l, e[4] = c, e[5] = y) : y = e[5];
|
|
326
|
+
let p;
|
|
327
|
+
return e[6] !== i || e[7] !== y ? (p = /* @__PURE__ */ H(Ae, { variant: "narrow", flexShrink: 0, gap: "2xs", bg: "bg", children: [
|
|
328
|
+
i,
|
|
329
|
+
y
|
|
330
|
+
] }), e[6] = i, e[7] = y, e[8] = p) : p = e[8], p;
|
|
331
|
+
}, rt = 600, nt = (r) => r instanceof Error ? r.message : "Failed to load file.", it = (r) => {
|
|
332
|
+
const {
|
|
333
|
+
workbench: e,
|
|
334
|
+
navigation: t,
|
|
335
|
+
sectionId: l
|
|
336
|
+
} = r;
|
|
337
|
+
if (!t || !F(e).getTreeRenderer(t.treeId)) return;
|
|
338
|
+
if (l && t.anchors.some((i) => i.id === l)) {
|
|
339
|
+
F(e).setSelectedNode(t.treeId, l);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
const n = F(e).getTreeState(t.treeId).selectedNodeId;
|
|
343
|
+
n && t.anchors.some((i) => i.id === n) && F(e).setSelectedNode(t.treeId, void 0);
|
|
344
|
+
}, ot = (r, e) => {
|
|
345
|
+
if (!e) return;
|
|
346
|
+
const t = F(r).getTreeRenderer(e.treeId) ? F(r).getTreeState(e.treeId).selectedNodeId : void 0;
|
|
347
|
+
return {
|
|
348
|
+
anchors: e.anchors,
|
|
349
|
+
targetId: Ve(e, t)
|
|
350
|
+
};
|
|
351
|
+
}, pt = (r) => {
|
|
352
|
+
const e = le(69), {
|
|
353
|
+
workbench: t,
|
|
354
|
+
contribution: l
|
|
355
|
+
} = r, n = r.placement?.resource;
|
|
356
|
+
let i, c;
|
|
357
|
+
e[0] !== n || e[1] !== t ? (i = qe(n), c = ot(t, i), e[0] = n, e[1] = t, e[2] = i, e[3] = c) : (i = e[2], c = e[3]);
|
|
358
|
+
const y = c;
|
|
359
|
+
let p;
|
|
360
|
+
e[4] !== l.id || e[5] !== n ? (p = Ze({
|
|
361
|
+
fileRendererId: l.id,
|
|
362
|
+
resource: n
|
|
363
|
+
}), e[4] = l.id, e[5] = n, e[6] = p) : p = e[6];
|
|
364
|
+
const d = p, [T, k] = me(null), [f, K] = me(null);
|
|
365
|
+
let _;
|
|
366
|
+
e[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (_ = {
|
|
367
|
+
dirty: !1,
|
|
368
|
+
saving: !1
|
|
369
|
+
}, e[7] = _) : _ = e[7];
|
|
370
|
+
const [g, N] = me(_), I = D(null), S = D(null), v = D(null);
|
|
371
|
+
let a, b;
|
|
372
|
+
e[8] !== n || e[9] !== i || e[10] !== t ? (a = () => {
|
|
373
|
+
const o = v.current, m = o && F(t).getTreeRenderer(o.treeId) ? F(t).getTreeState(o.treeId).selectedNodeId : void 0;
|
|
374
|
+
We({
|
|
375
|
+
previous: o,
|
|
376
|
+
current: i,
|
|
377
|
+
currentResourceKey: q(n),
|
|
378
|
+
selectedNodeId: m
|
|
379
|
+
}) && o && F(t).setSelectedNode(o.treeId, void 0), v.current = i ? {
|
|
380
|
+
resourceKey: q(n),
|
|
381
|
+
treeId: i.treeId,
|
|
382
|
+
anchorIds: i.anchors.map(lt)
|
|
383
|
+
} : null;
|
|
384
|
+
}, b = [n, i, t], e[8] = n, e[9] = i, e[10] = t, e[11] = a, e[12] = b) : (a = e[11], b = e[12]), ie(a, b);
|
|
385
|
+
const x = D(l), L = D(n), s = D(r.placement);
|
|
386
|
+
let u;
|
|
387
|
+
e[13] !== l || e[14] !== r.placement || e[15] !== n ? (u = () => {
|
|
388
|
+
x.current = l, L.current = n, s.current = r.placement;
|
|
389
|
+
}, e[13] = l, e[14] = r.placement, e[15] = n, e[16] = u) : u = e[16], ie(u);
|
|
390
|
+
const R = l.id, O = !!l.save;
|
|
391
|
+
let W;
|
|
392
|
+
e[17] !== R || e[18] !== O || e[19] !== d || e[20] !== r.placement?.instanceId || e[21] !== t ? (W = () => {
|
|
393
|
+
let o = !1, m = !1;
|
|
394
|
+
K(null);
|
|
395
|
+
const w = Ie(d);
|
|
396
|
+
k(w ? {
|
|
397
|
+
...w,
|
|
398
|
+
editorRevision: 1,
|
|
399
|
+
loadKey: d
|
|
400
|
+
} : null);
|
|
401
|
+
const ue = () => {
|
|
402
|
+
Promise.resolve(x.current.load(L.current)).then((C) => {
|
|
403
|
+
if (o || m)
|
|
404
|
+
return;
|
|
405
|
+
const j = Pe(C, d, I.current);
|
|
406
|
+
j && (K(null), k(j));
|
|
407
|
+
}).catch((C) => {
|
|
408
|
+
o || m || K({
|
|
409
|
+
loadKey: d,
|
|
410
|
+
message: nt(C)
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
};
|
|
414
|
+
I.current = O ? Qe({
|
|
415
|
+
binding: {
|
|
416
|
+
rendererId: R,
|
|
417
|
+
instanceId: r.placement?.instanceId ?? R,
|
|
418
|
+
resourceKey: q(L.current)
|
|
419
|
+
},
|
|
420
|
+
debounceMs: rt,
|
|
421
|
+
load: ue,
|
|
422
|
+
onStateChange: (C) => {
|
|
423
|
+
o || N(C);
|
|
424
|
+
},
|
|
425
|
+
save: (C, j) => Promise.resolve(x.current.save?.(L.current, C, j)).then((ne) => {
|
|
426
|
+
const ye = Ie(d);
|
|
427
|
+
return ye && !m && $e(d, {
|
|
428
|
+
...ye,
|
|
429
|
+
content: C
|
|
430
|
+
}), ne ?? void 0;
|
|
431
|
+
})
|
|
432
|
+
}) : null, w && I.current?.setBaseline(w.content, w.revision), N({
|
|
433
|
+
dirty: !1,
|
|
434
|
+
saving: !1
|
|
435
|
+
}), ue();
|
|
436
|
+
const we = t.resources.onWillRemove((C) => {
|
|
437
|
+
if (q(C) !== q(L.current))
|
|
438
|
+
return [];
|
|
439
|
+
m = !0;
|
|
440
|
+
const j = I.current?.markRemoved(), ne = s.current?.placementIdentity;
|
|
441
|
+
return j && ne ? [ne] : [];
|
|
442
|
+
}), _e = F(t).onDidRefreshFileRenderer((C) => {
|
|
443
|
+
if (m || C.fileRendererId !== R)
|
|
444
|
+
return;
|
|
445
|
+
const j = I.current;
|
|
446
|
+
j ? j.handleRefreshEvent(C) : ue();
|
|
447
|
+
});
|
|
448
|
+
return () => {
|
|
449
|
+
o = !0, _e.dispose(), we.dispose(), I.current?.flush(), I.current = null;
|
|
450
|
+
};
|
|
451
|
+
}, e[17] = R, e[18] = O, e[19] = d, e[20] = r.placement?.instanceId, e[21] = t, e[22] = W) : W = e[22];
|
|
452
|
+
const ce = r.placement?.instanceId;
|
|
453
|
+
let M;
|
|
454
|
+
e[23] !== R || e[24] !== O || e[25] !== d || e[26] !== ce || e[27] !== t ? (M = [R, O, t, d, ce], e[23] = R, e[24] = O, e[25] = d, e[26] = ce, e[27] = t, e[28] = M) : M = e[28], ie(W, M);
|
|
455
|
+
let U, Y;
|
|
456
|
+
e[29] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (Y = () => {
|
|
457
|
+
const o = () => I.current?.flush(), m = () => {
|
|
458
|
+
document.visibilityState === "hidden" && o();
|
|
459
|
+
};
|
|
460
|
+
return window.addEventListener("beforeunload", o), document.addEventListener("visibilitychange", m), () => {
|
|
461
|
+
window.removeEventListener("beforeunload", o), document.removeEventListener("visibilitychange", m);
|
|
462
|
+
};
|
|
463
|
+
}, U = [], e[29] = U, e[30] = Y) : (U = e[29], Y = e[30]), ie(Y, U);
|
|
464
|
+
let z;
|
|
465
|
+
e[31] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (z = (o) => {
|
|
466
|
+
I.current?.handleChange(o);
|
|
467
|
+
}, e[31] = z) : z = e[31];
|
|
468
|
+
const Re = z;
|
|
469
|
+
let G;
|
|
470
|
+
e[32] !== d || e[33] !== T ? (G = et(T, d) ? T : null, e[32] = d, e[33] = T, e[34] = G) : G = e[34];
|
|
471
|
+
const E = G, X = E ? `${E.loadKey}:${E.editorRevision}` : "";
|
|
472
|
+
let J, Q;
|
|
473
|
+
e[35] !== X || e[36] !== i ? (J = () => {
|
|
474
|
+
if (!X || i)
|
|
475
|
+
return;
|
|
476
|
+
const o = S.current;
|
|
477
|
+
o && requestAnimationFrame(() => {
|
|
478
|
+
let m = o.parentElement;
|
|
479
|
+
for (; m; ) {
|
|
480
|
+
const w = getComputedStyle(m).overflowY;
|
|
481
|
+
["auto", "scroll", "overlay"].includes(w) && m.scrollHeight > m.clientHeight && (m.scrollTop = 0), m = m.parentElement;
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
}, Q = [X, i], e[35] = X, e[36] = i, e[37] = J, e[38] = Q) : (J = e[37], Q = e[38]), Ke(J, Q);
|
|
485
|
+
const A = f?.loadKey === d ? f.message : void 0;
|
|
486
|
+
let Z;
|
|
487
|
+
e[39] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (Z = () => I.current?.retryLoad(), e[39] = Z) : Z = e[39];
|
|
488
|
+
const ve = Z;
|
|
489
|
+
let ee;
|
|
490
|
+
e[40] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (ee = () => I.current?.retry(), e[40] = ee) : ee = e[40];
|
|
491
|
+
const Ne = ee;
|
|
492
|
+
if (A && !E) {
|
|
493
|
+
let o;
|
|
494
|
+
e[41] !== A ? (o = /* @__PURE__ */ h(se, { color: "fg.muted", children: A }), e[41] = A, e[42] = o) : o = e[42];
|
|
495
|
+
let m;
|
|
496
|
+
e[43] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (m = /* @__PURE__ */ h(Se, { size: "xs", variant: "subtle", onClick: ve, children: "Retry" }), e[43] = m) : m = e[43];
|
|
497
|
+
let w;
|
|
498
|
+
return e[44] !== o ? (w = /* @__PURE__ */ H(oe, { h: "full", minH: "0", bg: "bg", p: "md", flexDirection: "column", gap: "sm", children: [
|
|
499
|
+
o,
|
|
500
|
+
m
|
|
501
|
+
] }), e[44] = o, e[45] = w) : w = e[45], w;
|
|
502
|
+
}
|
|
503
|
+
if (!E) {
|
|
504
|
+
let o;
|
|
505
|
+
return e[46] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ h(oe, { h: "full", minH: "0", bg: "bg", children: /* @__PURE__ */ h(Fe, { size: "sm" }) }), e[46] = o) : o = e[46], o;
|
|
506
|
+
}
|
|
507
|
+
const ae = `${E.loadKey}:${E.editorRevision}`;
|
|
508
|
+
let P = null;
|
|
509
|
+
if (g.removed) {
|
|
510
|
+
let o;
|
|
511
|
+
e[47] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ h(he, { message: "This resource was removed. Your draft is kept here. Copy it before closing this tab." }), e[47] = o) : o = e[47], P = o;
|
|
512
|
+
} else if (A) {
|
|
513
|
+
let o;
|
|
514
|
+
e[48] !== A ? (o = /* @__PURE__ */ h(he, { message: A, onRetry: ve }), e[48] = A, e[49] = o) : o = e[49], P = o;
|
|
515
|
+
} else if (g.saveError) {
|
|
516
|
+
let o;
|
|
517
|
+
e[50] !== g.saveError ? (o = /* @__PURE__ */ h(he, { message: g.saveError, onRetry: Ne }), e[50] = g.saveError, e[51] = o) : o = e[51], P = o;
|
|
518
|
+
}
|
|
519
|
+
let te;
|
|
520
|
+
e[52] !== i || e[53] !== t ? (te = (o) => {
|
|
521
|
+
it({
|
|
522
|
+
workbench: t,
|
|
523
|
+
navigation: i,
|
|
524
|
+
sectionId: o
|
|
525
|
+
});
|
|
526
|
+
}, e[52] = i, e[53] = t, e[54] = te) : te = e[54];
|
|
527
|
+
const Ce = te;
|
|
528
|
+
let $;
|
|
529
|
+
e[55] !== E.fileName || e[56] !== E.filePath ? ($ = E.filePath ? /* @__PURE__ */ h(tt, { fileName: E.fileName ?? E.filePath, filePath: E.filePath }) : null, e[55] = E.fileName, e[56] = E.filePath, e[57] = $) : $ = e[57];
|
|
530
|
+
const xe = P, de = !!l.save, fe = i ? Ce : void 0;
|
|
531
|
+
let B;
|
|
532
|
+
e[58] !== l.title || e[59] !== E || e[60] !== ae || e[61] !== y || e[62] !== P || e[63] !== de || e[64] !== fe ? (B = /* @__PURE__ */ h(ge, { flex: "1", minH: "0", children: /* @__PURE__ */ h(Je, { content: E, editorKey: ae, errorNotice: xe, contributionCanSave: de, onActiveSectionChange: fe, onChange: Re, rendererRef: S, sectionNavigation: y, title: l.title }) }), e[58] = l.title, e[59] = E, e[60] = ae, e[61] = y, e[62] = P, e[63] = de, e[64] = fe, e[65] = B) : B = e[65];
|
|
533
|
+
let re;
|
|
534
|
+
return e[66] !== $ || e[67] !== B ? (re = /* @__PURE__ */ H(V, { direction: "column", h: "full", minH: "0", bg: "bg", children: [
|
|
535
|
+
$,
|
|
536
|
+
B
|
|
537
|
+
] }), e[66] = $, e[67] = B, e[68] = re) : re = e[68], re;
|
|
538
|
+
};
|
|
539
|
+
function lt(r) {
|
|
540
|
+
return r.id;
|
|
541
|
+
}
|
|
542
|
+
export {
|
|
543
|
+
pt as WorkbenchFileRendererView
|
|
544
|
+
};
|
|
545
|
+
//# sourceMappingURL=file-renderer-view-BJ3LX04R.js.map
|