superleap-code-editor 1.0.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 +356 -0
- package/dist/components/codeEditorWrapper.d.ts +30 -0
- package/dist/components/codeEditorWrapper.d.ts.map +1 -0
- package/dist/components/editor/codeEditor.d.ts +12 -0
- package/dist/components/editor/codeEditor.d.ts.map +1 -0
- package/dist/components/layout/editorLayout.d.ts +11 -0
- package/dist/components/layout/editorLayout.d.ts.map +1 -0
- package/dist/components/layout/header.d.ts +9 -0
- package/dist/components/layout/header.d.ts.map +1 -0
- package/dist/components/layout/sidebar.d.ts +8 -0
- package/dist/components/layout/sidebar.d.ts.map +1 -0
- package/dist/components/panels/dataExplorer.d.ts +3 -0
- package/dist/components/panels/dataExplorer.d.ts.map +1 -0
- package/dist/components/panels/fileExplorer.d.ts +13 -0
- package/dist/components/panels/fileExplorer.d.ts.map +1 -0
- package/dist/components/panels/functionLibrary.d.ts +3 -0
- package/dist/components/panels/functionLibrary.d.ts.map +1 -0
- package/dist/components/panels/previewPanel.d.ts +7 -0
- package/dist/components/panels/previewPanel.d.ts.map +1 -0
- package/dist/components/panels/testRunner.d.ts +3 -0
- package/dist/components/panels/testRunner.d.ts.map +1 -0
- package/dist/components/panels/versionHistory.d.ts +3 -0
- package/dist/components/panels/versionHistory.d.ts.map +1 -0
- package/dist/examples/codeEditorExamples.d.ts +6 -0
- package/dist/examples/codeEditorExamples.d.ts.map +1 -0
- package/dist/hooks/useFileManager.d.ts +14 -0
- package/dist/hooks/useFileManager.d.ts.map +1 -0
- package/dist/index.cjs.js +22 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +847 -0
- package/dist/providers/fileProviders.d.ts +36 -0
- package/dist/providers/fileProviders.d.ts.map +1 -0
- package/dist/types/fileTypes.d.ts +48 -0
- package/dist/types/fileTypes.d.ts.map +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,847 @@
|
|
|
1
|
+
import K, { useState as C, useCallback as _, useEffect as G } from "react";
|
|
2
|
+
import me from "@monaco-editor/react";
|
|
3
|
+
import { Tooltip as X, Button as D, Splitter as F, Alert as he, Tree as pe } from "antd";
|
|
4
|
+
import { Alert as Ve, Button as qe, Splitter as Je, Tooltip as Ge, Tree as Xe } from "antd";
|
|
5
|
+
import { IconFolderOpen as ee, IconDatabase as ge, IconCode as ve, IconHistory as xe, IconFlask as Ee, IconSettings as ye, IconPlus as be, IconFile as je } from "@tabler/icons-react";
|
|
6
|
+
var N = { exports: {} }, k = {};
|
|
7
|
+
/**
|
|
8
|
+
* @license React
|
|
9
|
+
* react-jsx-runtime.production.js
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the MIT license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
var H;
|
|
17
|
+
function Fe() {
|
|
18
|
+
if (H) return k;
|
|
19
|
+
H = 1;
|
|
20
|
+
var i = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
|
|
21
|
+
function r(n, a, l) {
|
|
22
|
+
var d = null;
|
|
23
|
+
if (l !== void 0 && (d = "" + l), a.key !== void 0 && (d = "" + a.key), "key" in a) {
|
|
24
|
+
l = {};
|
|
25
|
+
for (var p in a)
|
|
26
|
+
p !== "key" && (l[p] = a[p]);
|
|
27
|
+
} else l = a;
|
|
28
|
+
return a = l.ref, {
|
|
29
|
+
$$typeof: i,
|
|
30
|
+
type: n,
|
|
31
|
+
key: d,
|
|
32
|
+
ref: a !== void 0 ? a : null,
|
|
33
|
+
props: l
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return k.Fragment = t, k.jsx = r, k.jsxs = r, k;
|
|
37
|
+
}
|
|
38
|
+
var S = {};
|
|
39
|
+
/**
|
|
40
|
+
* @license React
|
|
41
|
+
* react-jsx-runtime.development.js
|
|
42
|
+
*
|
|
43
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the MIT license found in the
|
|
46
|
+
* LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/
|
|
48
|
+
var Z;
|
|
49
|
+
function we() {
|
|
50
|
+
return Z || (Z = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
51
|
+
function i(e) {
|
|
52
|
+
if (e == null) return null;
|
|
53
|
+
if (typeof e == "function")
|
|
54
|
+
return e.$$typeof === fe ? null : e.displayName || e.name || null;
|
|
55
|
+
if (typeof e == "string") return e;
|
|
56
|
+
switch (e) {
|
|
57
|
+
case T:
|
|
58
|
+
return "Fragment";
|
|
59
|
+
case u:
|
|
60
|
+
return "Profiler";
|
|
61
|
+
case O:
|
|
62
|
+
return "StrictMode";
|
|
63
|
+
case ae:
|
|
64
|
+
return "Suspense";
|
|
65
|
+
case se:
|
|
66
|
+
return "SuspenseList";
|
|
67
|
+
case ce:
|
|
68
|
+
return "Activity";
|
|
69
|
+
}
|
|
70
|
+
if (typeof e == "object")
|
|
71
|
+
switch (typeof e.tag == "number" && console.error(
|
|
72
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
73
|
+
), e.$$typeof) {
|
|
74
|
+
case A:
|
|
75
|
+
return "Portal";
|
|
76
|
+
case ie:
|
|
77
|
+
return (e.displayName || "Context") + ".Provider";
|
|
78
|
+
case g:
|
|
79
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
80
|
+
case oe:
|
|
81
|
+
var s = e.render;
|
|
82
|
+
return e = e.displayName, e || (e = s.displayName || s.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
83
|
+
case le:
|
|
84
|
+
return s = e.displayName || null, s !== null ? s : i(e.type) || "Memo";
|
|
85
|
+
case M:
|
|
86
|
+
s = e._payload, e = e._init;
|
|
87
|
+
try {
|
|
88
|
+
return i(e(s));
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
function t(e) {
|
|
95
|
+
return "" + e;
|
|
96
|
+
}
|
|
97
|
+
function r(e) {
|
|
98
|
+
try {
|
|
99
|
+
t(e);
|
|
100
|
+
var s = !1;
|
|
101
|
+
} catch {
|
|
102
|
+
s = !0;
|
|
103
|
+
}
|
|
104
|
+
if (s) {
|
|
105
|
+
s = console;
|
|
106
|
+
var f = s.error, m = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
107
|
+
return f.call(
|
|
108
|
+
s,
|
|
109
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
110
|
+
m
|
|
111
|
+
), t(e);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function n(e) {
|
|
115
|
+
if (e === T) return "<>";
|
|
116
|
+
if (typeof e == "object" && e !== null && e.$$typeof === M)
|
|
117
|
+
return "<...>";
|
|
118
|
+
try {
|
|
119
|
+
var s = i(e);
|
|
120
|
+
return s ? "<" + s + ">" : "<...>";
|
|
121
|
+
} catch {
|
|
122
|
+
return "<...>";
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function a() {
|
|
126
|
+
var e = P.A;
|
|
127
|
+
return e === null ? null : e.getOwner();
|
|
128
|
+
}
|
|
129
|
+
function l() {
|
|
130
|
+
return Error("react-stack-top-frame");
|
|
131
|
+
}
|
|
132
|
+
function d(e) {
|
|
133
|
+
if (B.call(e, "key")) {
|
|
134
|
+
var s = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
135
|
+
if (s && s.isReactWarning) return !1;
|
|
136
|
+
}
|
|
137
|
+
return e.key !== void 0;
|
|
138
|
+
}
|
|
139
|
+
function p(e, s) {
|
|
140
|
+
function f() {
|
|
141
|
+
W || (W = !0, console.error(
|
|
142
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
143
|
+
s
|
|
144
|
+
));
|
|
145
|
+
}
|
|
146
|
+
f.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
147
|
+
get: f,
|
|
148
|
+
configurable: !0
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function x() {
|
|
152
|
+
var e = i(this.type);
|
|
153
|
+
return U[e] || (U[e] = !0, console.error(
|
|
154
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
155
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
156
|
+
}
|
|
157
|
+
function b(e, s, f, m, j, E, $, L) {
|
|
158
|
+
return f = E.ref, e = {
|
|
159
|
+
$$typeof: w,
|
|
160
|
+
type: e,
|
|
161
|
+
key: s,
|
|
162
|
+
props: E,
|
|
163
|
+
_owner: j
|
|
164
|
+
}, (f !== void 0 ? f : null) !== null ? Object.defineProperty(e, "ref", {
|
|
165
|
+
enumerable: !1,
|
|
166
|
+
get: x
|
|
167
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
168
|
+
configurable: !1,
|
|
169
|
+
enumerable: !1,
|
|
170
|
+
writable: !0,
|
|
171
|
+
value: 0
|
|
172
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
173
|
+
configurable: !1,
|
|
174
|
+
enumerable: !1,
|
|
175
|
+
writable: !0,
|
|
176
|
+
value: null
|
|
177
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
178
|
+
configurable: !1,
|
|
179
|
+
enumerable: !1,
|
|
180
|
+
writable: !0,
|
|
181
|
+
value: $
|
|
182
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
183
|
+
configurable: !1,
|
|
184
|
+
enumerable: !1,
|
|
185
|
+
writable: !0,
|
|
186
|
+
value: L
|
|
187
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
188
|
+
}
|
|
189
|
+
function c(e, s, f, m, j, E, $, L) {
|
|
190
|
+
var h = s.children;
|
|
191
|
+
if (h !== void 0)
|
|
192
|
+
if (m)
|
|
193
|
+
if (ue(h)) {
|
|
194
|
+
for (m = 0; m < h.length; m++)
|
|
195
|
+
y(h[m]);
|
|
196
|
+
Object.freeze && Object.freeze(h);
|
|
197
|
+
} else
|
|
198
|
+
console.error(
|
|
199
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
200
|
+
);
|
|
201
|
+
else y(h);
|
|
202
|
+
if (B.call(s, "key")) {
|
|
203
|
+
h = i(e);
|
|
204
|
+
var R = Object.keys(s).filter(function(de) {
|
|
205
|
+
return de !== "key";
|
|
206
|
+
});
|
|
207
|
+
m = 0 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}", J[h + m] || (R = 0 < R.length ? "{" + R.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
208
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
209
|
+
let props = %s;
|
|
210
|
+
<%s {...props} />
|
|
211
|
+
React keys must be passed directly to JSX without using spread:
|
|
212
|
+
let props = %s;
|
|
213
|
+
<%s key={someKey} {...props} />`,
|
|
214
|
+
m,
|
|
215
|
+
h,
|
|
216
|
+
R,
|
|
217
|
+
h
|
|
218
|
+
), J[h + m] = !0);
|
|
219
|
+
}
|
|
220
|
+
if (h = null, f !== void 0 && (r(f), h = "" + f), d(s) && (r(s.key), h = "" + s.key), "key" in s) {
|
|
221
|
+
f = {};
|
|
222
|
+
for (var z in s)
|
|
223
|
+
z !== "key" && (f[z] = s[z]);
|
|
224
|
+
} else f = s;
|
|
225
|
+
return h && p(
|
|
226
|
+
f,
|
|
227
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
228
|
+
), b(
|
|
229
|
+
e,
|
|
230
|
+
h,
|
|
231
|
+
E,
|
|
232
|
+
j,
|
|
233
|
+
a(),
|
|
234
|
+
f,
|
|
235
|
+
$,
|
|
236
|
+
L
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
function y(e) {
|
|
240
|
+
typeof e == "object" && e !== null && e.$$typeof === w && e._store && (e._store.validated = 1);
|
|
241
|
+
}
|
|
242
|
+
var v = K, w = Symbol.for("react.transitional.element"), A = Symbol.for("react.portal"), T = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), u = Symbol.for("react.profiler"), g = Symbol.for("react.consumer"), ie = Symbol.for("react.context"), oe = Symbol.for("react.forward_ref"), ae = Symbol.for("react.suspense"), se = Symbol.for("react.suspense_list"), le = Symbol.for("react.memo"), M = Symbol.for("react.lazy"), ce = Symbol.for("react.activity"), fe = Symbol.for("react.client.reference"), P = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, B = Object.prototype.hasOwnProperty, ue = Array.isArray, I = console.createTask ? console.createTask : function() {
|
|
243
|
+
return null;
|
|
244
|
+
};
|
|
245
|
+
v = {
|
|
246
|
+
react_stack_bottom_frame: function(e) {
|
|
247
|
+
return e();
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
var W, U = {}, V = v.react_stack_bottom_frame.bind(
|
|
251
|
+
v,
|
|
252
|
+
l
|
|
253
|
+
)(), q = I(n(l)), J = {};
|
|
254
|
+
S.Fragment = T, S.jsx = function(e, s, f, m, j) {
|
|
255
|
+
var E = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
256
|
+
return c(
|
|
257
|
+
e,
|
|
258
|
+
s,
|
|
259
|
+
f,
|
|
260
|
+
!1,
|
|
261
|
+
m,
|
|
262
|
+
j,
|
|
263
|
+
E ? Error("react-stack-top-frame") : V,
|
|
264
|
+
E ? I(n(e)) : q
|
|
265
|
+
);
|
|
266
|
+
}, S.jsxs = function(e, s, f, m, j) {
|
|
267
|
+
var E = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
268
|
+
return c(
|
|
269
|
+
e,
|
|
270
|
+
s,
|
|
271
|
+
f,
|
|
272
|
+
!0,
|
|
273
|
+
m,
|
|
274
|
+
j,
|
|
275
|
+
E ? Error("react-stack-top-frame") : V,
|
|
276
|
+
E ? I(n(e)) : q
|
|
277
|
+
);
|
|
278
|
+
};
|
|
279
|
+
})()), S;
|
|
280
|
+
}
|
|
281
|
+
var Q;
|
|
282
|
+
function Re() {
|
|
283
|
+
return Q || (Q = 1, process.env.NODE_ENV === "production" ? N.exports = Fe() : N.exports = we()), N.exports;
|
|
284
|
+
}
|
|
285
|
+
var o = Re();
|
|
286
|
+
function _e(i) {
|
|
287
|
+
const [t, r] = C([]), [n, a] = C(null), [l, d] = C(""), [p, x] = C(!1), [b, c] = C(null), y = _(async () => {
|
|
288
|
+
try {
|
|
289
|
+
x(!0), c(null);
|
|
290
|
+
const u = await i.getFiles();
|
|
291
|
+
if (r(u), !n && u.length > 0) {
|
|
292
|
+
const g = te(u);
|
|
293
|
+
g && a(g.id);
|
|
294
|
+
}
|
|
295
|
+
} catch (u) {
|
|
296
|
+
c(u instanceof Error ? u.message : "Failed to load files");
|
|
297
|
+
} finally {
|
|
298
|
+
x(!1);
|
|
299
|
+
}
|
|
300
|
+
}, [i, n]), v = _(
|
|
301
|
+
async (u) => {
|
|
302
|
+
try {
|
|
303
|
+
x(!0), c(null);
|
|
304
|
+
const g = await i.getFileContent(u);
|
|
305
|
+
d(g);
|
|
306
|
+
} catch (g) {
|
|
307
|
+
c(
|
|
308
|
+
g instanceof Error ? g.message : "Failed to load file content"
|
|
309
|
+
), d("");
|
|
310
|
+
} finally {
|
|
311
|
+
x(!1);
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
[i]
|
|
315
|
+
), w = _(
|
|
316
|
+
async (u) => {
|
|
317
|
+
if (n)
|
|
318
|
+
try {
|
|
319
|
+
c(null), await i.updateFileContent(n, u), d(u), r(
|
|
320
|
+
(g) => ne(g, n, { content: u })
|
|
321
|
+
);
|
|
322
|
+
} catch (g) {
|
|
323
|
+
c(
|
|
324
|
+
g instanceof Error ? g.message : "Failed to update file content"
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
[n, i]
|
|
329
|
+
), A = _(
|
|
330
|
+
(u) => {
|
|
331
|
+
a(u), v(u);
|
|
332
|
+
},
|
|
333
|
+
[v]
|
|
334
|
+
), T = _(() => {
|
|
335
|
+
y();
|
|
336
|
+
}, [y]), O = _(
|
|
337
|
+
(u) => re(t, u),
|
|
338
|
+
[t]
|
|
339
|
+
);
|
|
340
|
+
return G(() => {
|
|
341
|
+
y();
|
|
342
|
+
}, [y]), G(() => {
|
|
343
|
+
n && v(n);
|
|
344
|
+
}, [n, v]), {
|
|
345
|
+
files: t,
|
|
346
|
+
activeFile: n,
|
|
347
|
+
fileContent: l,
|
|
348
|
+
loading: p,
|
|
349
|
+
error: b,
|
|
350
|
+
setActiveFile: A,
|
|
351
|
+
updateFileContent: w,
|
|
352
|
+
refreshFiles: T,
|
|
353
|
+
getFileById: O
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
function te(i) {
|
|
357
|
+
for (const t of i) {
|
|
358
|
+
if (t.type === "file")
|
|
359
|
+
return t;
|
|
360
|
+
if (t.children) {
|
|
361
|
+
const r = te(t.children);
|
|
362
|
+
if (r) return r;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
function re(i, t) {
|
|
368
|
+
for (const r of i) {
|
|
369
|
+
if (r.id === t) return r;
|
|
370
|
+
if (r.children) {
|
|
371
|
+
const n = re(r.children, t);
|
|
372
|
+
if (n) return n;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
function ne(i, t, r) {
|
|
378
|
+
return i.map((n) => n.id === t ? { ...n, ...r } : n.children ? {
|
|
379
|
+
...n,
|
|
380
|
+
children: ne(n.children, t, r)
|
|
381
|
+
} : n);
|
|
382
|
+
}
|
|
383
|
+
class Te {
|
|
384
|
+
config;
|
|
385
|
+
files = [];
|
|
386
|
+
constructor(t) {
|
|
387
|
+
this.config = t;
|
|
388
|
+
}
|
|
389
|
+
async getFiles() {
|
|
390
|
+
return this.files.length === 0 && await this.loadFiles(), this.files;
|
|
391
|
+
}
|
|
392
|
+
async getFileContent(t) {
|
|
393
|
+
if (t === "main-function")
|
|
394
|
+
return await this.config.fetchFunction(
|
|
395
|
+
this.config.functionId,
|
|
396
|
+
this.config.version
|
|
397
|
+
);
|
|
398
|
+
throw new Error(`File ${t} not found`);
|
|
399
|
+
}
|
|
400
|
+
async updateFileContent(t, r) {
|
|
401
|
+
const n = this.findFileById(t);
|
|
402
|
+
n && (n.content = r), console.log(`Updated file ${t} with content:`, r);
|
|
403
|
+
}
|
|
404
|
+
async getFileMetadata(t) {
|
|
405
|
+
return this.findFileById(t)?.metadata || {};
|
|
406
|
+
}
|
|
407
|
+
async loadFiles() {
|
|
408
|
+
this.files = [
|
|
409
|
+
{
|
|
410
|
+
id: "main-function",
|
|
411
|
+
name: "function.js",
|
|
412
|
+
type: "file",
|
|
413
|
+
path: "/function.js",
|
|
414
|
+
metadata: {
|
|
415
|
+
language: "javascript",
|
|
416
|
+
lastModified: /* @__PURE__ */ new Date()
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
id: "versions",
|
|
421
|
+
name: "versions",
|
|
422
|
+
type: "folder",
|
|
423
|
+
path: "/versions",
|
|
424
|
+
children: this.config.versionList.map((t) => ({
|
|
425
|
+
id: `version-${t}`,
|
|
426
|
+
name: `v${t}.js`,
|
|
427
|
+
type: "file",
|
|
428
|
+
path: `/versions/v${t}.js`,
|
|
429
|
+
metadata: {
|
|
430
|
+
language: "javascript"
|
|
431
|
+
}
|
|
432
|
+
}))
|
|
433
|
+
}
|
|
434
|
+
];
|
|
435
|
+
}
|
|
436
|
+
findFileById(t) {
|
|
437
|
+
const r = (n) => {
|
|
438
|
+
for (const a of n) {
|
|
439
|
+
if (a.id === t) return a;
|
|
440
|
+
if (a.children) {
|
|
441
|
+
const l = r(a.children);
|
|
442
|
+
if (l) return l;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return null;
|
|
446
|
+
};
|
|
447
|
+
return r(this.files);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
class Ce {
|
|
451
|
+
config;
|
|
452
|
+
files = [];
|
|
453
|
+
constructor(t) {
|
|
454
|
+
this.config = t, this.initializeFiles();
|
|
455
|
+
}
|
|
456
|
+
async getFiles() {
|
|
457
|
+
return this.files;
|
|
458
|
+
}
|
|
459
|
+
async getFileContent(t) {
|
|
460
|
+
if (t === "form-code")
|
|
461
|
+
return this.config.codeContent;
|
|
462
|
+
throw new Error(`File ${t} not found`);
|
|
463
|
+
}
|
|
464
|
+
async updateFileContent(t, r) {
|
|
465
|
+
if (t === "form-code") {
|
|
466
|
+
this.config.codeContent = r;
|
|
467
|
+
const n = this.files.find((a) => a.id === t);
|
|
468
|
+
n && (n.content = r);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
async getFileMetadata(t) {
|
|
472
|
+
return this.findFileById(t)?.metadata || {};
|
|
473
|
+
}
|
|
474
|
+
initializeFiles() {
|
|
475
|
+
this.files = [
|
|
476
|
+
{
|
|
477
|
+
id: "form-code",
|
|
478
|
+
name: this.config.fileName || "code.js",
|
|
479
|
+
type: "file",
|
|
480
|
+
path: `/${this.config.fileName || "code.js"}`,
|
|
481
|
+
content: this.config.codeContent,
|
|
482
|
+
metadata: {
|
|
483
|
+
language: this.config.language || "javascript",
|
|
484
|
+
lastModified: /* @__PURE__ */ new Date()
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
];
|
|
488
|
+
}
|
|
489
|
+
findFileById(t) {
|
|
490
|
+
return this.files.find((r) => r.id === t) || null;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
class ke {
|
|
494
|
+
config;
|
|
495
|
+
files = [];
|
|
496
|
+
constructor(t) {
|
|
497
|
+
this.config = t, this.initializeFiles();
|
|
498
|
+
}
|
|
499
|
+
async getFiles() {
|
|
500
|
+
return this.files;
|
|
501
|
+
}
|
|
502
|
+
async getFileContent(t) {
|
|
503
|
+
const r = this.findFileById(t);
|
|
504
|
+
if (!r || !r.metadata?.url)
|
|
505
|
+
throw new Error(`File ${t} not found`);
|
|
506
|
+
try {
|
|
507
|
+
const n = await fetch(r.metadata.url);
|
|
508
|
+
if (!n.ok)
|
|
509
|
+
throw new Error(`Failed to fetch file: ${n.statusText}`);
|
|
510
|
+
return await n.text();
|
|
511
|
+
} catch (n) {
|
|
512
|
+
throw new Error(`Error fetching file content: ${n}`);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
async updateFileContent(t, r) {
|
|
516
|
+
console.log(`Would save file ${t} content to backend:`, r);
|
|
517
|
+
const n = this.findFileById(t);
|
|
518
|
+
n && (n.content = r);
|
|
519
|
+
}
|
|
520
|
+
async getFileMetadata(t) {
|
|
521
|
+
return this.findFileById(t)?.metadata || {};
|
|
522
|
+
}
|
|
523
|
+
initializeFiles() {
|
|
524
|
+
this.files = this.config.fileUrls.map((t, r) => ({
|
|
525
|
+
id: `url-file-${r}`,
|
|
526
|
+
name: t.name,
|
|
527
|
+
type: "file",
|
|
528
|
+
path: `/${t.name}`,
|
|
529
|
+
metadata: {
|
|
530
|
+
language: t.type,
|
|
531
|
+
url: t.url,
|
|
532
|
+
lastModified: /* @__PURE__ */ new Date()
|
|
533
|
+
}
|
|
534
|
+
}));
|
|
535
|
+
}
|
|
536
|
+
findFileById(t) {
|
|
537
|
+
return this.files.find((r) => r.id === t) || null;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
function Se(i) {
|
|
541
|
+
if (i.workflowConfig)
|
|
542
|
+
return new Te(i.workflowConfig);
|
|
543
|
+
if (i.formConfig)
|
|
544
|
+
return new Ce(i.formConfig);
|
|
545
|
+
if (i.urlConfig)
|
|
546
|
+
return new ke(i.urlConfig);
|
|
547
|
+
throw new Error("No valid configuration provided");
|
|
548
|
+
}
|
|
549
|
+
const Ne = ({
|
|
550
|
+
value: i,
|
|
551
|
+
onChange: t,
|
|
552
|
+
language: r = "javascript",
|
|
553
|
+
filename: n,
|
|
554
|
+
readOnly: a = !1,
|
|
555
|
+
loading: l = !1
|
|
556
|
+
}) => {
|
|
557
|
+
const d = (p) => {
|
|
558
|
+
p !== void 0 && t(p);
|
|
559
|
+
};
|
|
560
|
+
return /* @__PURE__ */ o.jsx("div", { className: "h-full w-full", children: /* @__PURE__ */ o.jsx(
|
|
561
|
+
me,
|
|
562
|
+
{
|
|
563
|
+
height: "100%",
|
|
564
|
+
defaultLanguage: r,
|
|
565
|
+
defaultValue: i,
|
|
566
|
+
onChange: d,
|
|
567
|
+
theme: "vs-light",
|
|
568
|
+
options: {
|
|
569
|
+
minimap: {
|
|
570
|
+
enabled: !1
|
|
571
|
+
},
|
|
572
|
+
fontSize: 14,
|
|
573
|
+
wordWrap: "on",
|
|
574
|
+
automaticLayout: !0,
|
|
575
|
+
padding: {
|
|
576
|
+
top: 16
|
|
577
|
+
},
|
|
578
|
+
scrollBeyondLastLine: !1,
|
|
579
|
+
readOnly: a
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
) });
|
|
583
|
+
}, Ae = ({
|
|
584
|
+
activePanel: i,
|
|
585
|
+
setActivePanel: t
|
|
586
|
+
}) => {
|
|
587
|
+
const r = [
|
|
588
|
+
{
|
|
589
|
+
id: "explorer",
|
|
590
|
+
icon: ee,
|
|
591
|
+
label: "Files"
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
id: "data",
|
|
595
|
+
icon: ge,
|
|
596
|
+
label: "Data"
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
id: "functions",
|
|
600
|
+
icon: ve,
|
|
601
|
+
label: "Functions"
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
id: "versions",
|
|
605
|
+
icon: xe,
|
|
606
|
+
label: "Versions"
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
id: "tests",
|
|
610
|
+
icon: Ee,
|
|
611
|
+
label: "Tests"
|
|
612
|
+
}
|
|
613
|
+
];
|
|
614
|
+
return /* @__PURE__ */ o.jsxs("div", { className: "w-14 border-r border-slate-200 bg-white flex flex-col gap-4 items-center py-4", children: [
|
|
615
|
+
r.map((n) => {
|
|
616
|
+
const a = n.icon;
|
|
617
|
+
return /* @__PURE__ */ o.jsx(X, { title: n.label, placement: "right", children: /* @__PURE__ */ o.jsx(
|
|
618
|
+
D,
|
|
619
|
+
{
|
|
620
|
+
type: i === n.id ? "primary" : "text",
|
|
621
|
+
icon: /* @__PURE__ */ o.jsx(a, { size: 16 }),
|
|
622
|
+
onClick: () => t(n.id)
|
|
623
|
+
}
|
|
624
|
+
) }, n.id);
|
|
625
|
+
}),
|
|
626
|
+
/* @__PURE__ */ o.jsx("div", { className: "mt-auto", children: /* @__PURE__ */ o.jsx(X, { title: "Settings", placement: "right", children: /* @__PURE__ */ o.jsx(D, { type: "text", icon: /* @__PURE__ */ o.jsx(ye, { size: 20 }) }) }) })
|
|
627
|
+
] });
|
|
628
|
+
}, Oe = ({
|
|
629
|
+
leftPanel: i,
|
|
630
|
+
editor: t,
|
|
631
|
+
rightPanel: r,
|
|
632
|
+
activePanel: n,
|
|
633
|
+
setActivePanel: a
|
|
634
|
+
}) => /* @__PURE__ */ o.jsxs("div", { className: "flex flex-1 overflow-hidden", children: [
|
|
635
|
+
/* @__PURE__ */ o.jsx(Ae, { activePanel: n, setActivePanel: a }),
|
|
636
|
+
/* @__PURE__ */ o.jsx("div", { className: "flex-1", children: r ? /* @__PURE__ */ o.jsxs(
|
|
637
|
+
F,
|
|
638
|
+
{
|
|
639
|
+
style: { height: "100%" },
|
|
640
|
+
onResize: (l) => console.log(l),
|
|
641
|
+
children: [
|
|
642
|
+
/* @__PURE__ */ o.jsx(
|
|
643
|
+
F.Panel,
|
|
644
|
+
{
|
|
645
|
+
defaultSize: "25%",
|
|
646
|
+
min: "15%",
|
|
647
|
+
max: "40%",
|
|
648
|
+
className: "bg-white border-r border-slate-200",
|
|
649
|
+
collapsible: !0,
|
|
650
|
+
children: /* @__PURE__ */ o.jsx("div", { className: "h-full overflow-y-auto", children: i })
|
|
651
|
+
}
|
|
652
|
+
),
|
|
653
|
+
/* @__PURE__ */ o.jsx(F.Panel, { defaultSize: "50%", min: "30%", children: t }),
|
|
654
|
+
/* @__PURE__ */ o.jsx(
|
|
655
|
+
F.Panel,
|
|
656
|
+
{
|
|
657
|
+
defaultSize: "25%",
|
|
658
|
+
min: "20%",
|
|
659
|
+
max: "50%",
|
|
660
|
+
className: "bg-white border-l border-slate-200",
|
|
661
|
+
children: /* @__PURE__ */ o.jsx("div", { className: "h-full overflow-y-auto", children: r })
|
|
662
|
+
}
|
|
663
|
+
)
|
|
664
|
+
]
|
|
665
|
+
}
|
|
666
|
+
) : /* @__PURE__ */ o.jsxs(F, { style: { height: "100%" }, children: [
|
|
667
|
+
/* @__PURE__ */ o.jsx(
|
|
668
|
+
F.Panel,
|
|
669
|
+
{
|
|
670
|
+
defaultSize: "25%",
|
|
671
|
+
min: "15%",
|
|
672
|
+
max: "40%",
|
|
673
|
+
className: "bg-white border-r border-slate-200",
|
|
674
|
+
children: /* @__PURE__ */ o.jsx("div", { className: "h-full overflow-y-auto", children: i })
|
|
675
|
+
}
|
|
676
|
+
),
|
|
677
|
+
/* @__PURE__ */ o.jsx(F.Panel, { defaultSize: "75%", min: "60%", children: t })
|
|
678
|
+
] }) })
|
|
679
|
+
] }), Pe = ({
|
|
680
|
+
files: i,
|
|
681
|
+
activeFile: t,
|
|
682
|
+
onFileSelect: r,
|
|
683
|
+
loading: n = !1,
|
|
684
|
+
error: a = null,
|
|
685
|
+
onRefresh: l
|
|
686
|
+
}) => {
|
|
687
|
+
const d = (b) => b.map((c) => ({
|
|
688
|
+
title: c.name,
|
|
689
|
+
key: c.id,
|
|
690
|
+
icon: c.type === "file" ? /* @__PURE__ */ o.jsx(je, { size: 16, className: "text-slate-500 flex" }) : /* @__PURE__ */ o.jsx(ee, { size: 16, className: "text-slate-500 flex" }),
|
|
691
|
+
isLeaf: c.type === "file",
|
|
692
|
+
children: c.children ? d(c.children) : void 0,
|
|
693
|
+
metadata: c.metadata
|
|
694
|
+
})), p = d(i), x = (b, c) => {
|
|
695
|
+
c?.node.isLeaf && c.node.key && r(c.node.key);
|
|
696
|
+
};
|
|
697
|
+
return /* @__PURE__ */ o.jsxs("div", { className: "h-full", children: [
|
|
698
|
+
/* @__PURE__ */ o.jsxs("div", { className: "flex items-center justify-between p-4 border-b border-slate-200", children: [
|
|
699
|
+
/* @__PURE__ */ o.jsx("h2", { className: "font-medium text-sm", children: "Files" }),
|
|
700
|
+
/* @__PURE__ */ o.jsx("div", { className: "flex items-center gap-2", children: l && /* @__PURE__ */ o.jsx(
|
|
701
|
+
D,
|
|
702
|
+
{
|
|
703
|
+
type: "text",
|
|
704
|
+
icon: /* @__PURE__ */ o.jsx(be, { size: 16 }),
|
|
705
|
+
onClick: l,
|
|
706
|
+
loading: n,
|
|
707
|
+
title: "Refresh files"
|
|
708
|
+
}
|
|
709
|
+
) })
|
|
710
|
+
] }),
|
|
711
|
+
/* @__PURE__ */ o.jsxs("div", { className: "p-2", children: [
|
|
712
|
+
a && /* @__PURE__ */ o.jsx(
|
|
713
|
+
he,
|
|
714
|
+
{
|
|
715
|
+
message: "Error loading files",
|
|
716
|
+
description: a,
|
|
717
|
+
type: "error",
|
|
718
|
+
className: "mb-2"
|
|
719
|
+
}
|
|
720
|
+
),
|
|
721
|
+
/* @__PURE__ */ o.jsx(
|
|
722
|
+
pe,
|
|
723
|
+
{
|
|
724
|
+
treeData: p,
|
|
725
|
+
onSelect: x,
|
|
726
|
+
selectedKeys: t ? [t] : [],
|
|
727
|
+
showIcon: !0,
|
|
728
|
+
defaultExpandAll: !0,
|
|
729
|
+
showLine: !0,
|
|
730
|
+
className: "file-explorer-tree"
|
|
731
|
+
}
|
|
732
|
+
)
|
|
733
|
+
] })
|
|
734
|
+
] });
|
|
735
|
+
}, Y = ({
|
|
736
|
+
config: i,
|
|
737
|
+
rightPanel: t = !1
|
|
738
|
+
}) => {
|
|
739
|
+
const r = K.useMemo(
|
|
740
|
+
() => Se(i),
|
|
741
|
+
[i]
|
|
742
|
+
);
|
|
743
|
+
console.log({ config: i });
|
|
744
|
+
const {
|
|
745
|
+
files: n,
|
|
746
|
+
activeFile: a,
|
|
747
|
+
fileContent: l,
|
|
748
|
+
loading: d,
|
|
749
|
+
error: p,
|
|
750
|
+
setActiveFile: x,
|
|
751
|
+
updateFileContent: b,
|
|
752
|
+
refreshFiles: c,
|
|
753
|
+
getFileById: y
|
|
754
|
+
} = _e(r), v = a ? y(a) : null, w = v?.metadata?.language || "javascript";
|
|
755
|
+
return /* @__PURE__ */ o.jsx(
|
|
756
|
+
Oe,
|
|
757
|
+
{
|
|
758
|
+
leftPanel: /* @__PURE__ */ o.jsx(
|
|
759
|
+
Pe,
|
|
760
|
+
{
|
|
761
|
+
files: n,
|
|
762
|
+
activeFile: a,
|
|
763
|
+
onFileSelect: x,
|
|
764
|
+
loading: d,
|
|
765
|
+
error: p,
|
|
766
|
+
onRefresh: c
|
|
767
|
+
}
|
|
768
|
+
),
|
|
769
|
+
editor: /* @__PURE__ */ o.jsx(
|
|
770
|
+
Ne,
|
|
771
|
+
{
|
|
772
|
+
value: l,
|
|
773
|
+
onChange: b,
|
|
774
|
+
language: w,
|
|
775
|
+
filename: v?.name,
|
|
776
|
+
readOnly: i.settings?.readOnly,
|
|
777
|
+
loading: d
|
|
778
|
+
}
|
|
779
|
+
),
|
|
780
|
+
rightPanel: t,
|
|
781
|
+
activePanel: "explorer",
|
|
782
|
+
setActivePanel: () => {
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
);
|
|
786
|
+
}, De = ({
|
|
787
|
+
functionId: i,
|
|
788
|
+
version: t,
|
|
789
|
+
versionList: r,
|
|
790
|
+
fetchFunction: n,
|
|
791
|
+
fetchVersionList: a
|
|
792
|
+
}) => {
|
|
793
|
+
const l = {
|
|
794
|
+
workflowConfig: {
|
|
795
|
+
functionId: i,
|
|
796
|
+
version: t,
|
|
797
|
+
versionList: r,
|
|
798
|
+
fetchFunction: n,
|
|
799
|
+
fetchVersionList: a
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
return /* @__PURE__ */ o.jsx(Y, { config: l });
|
|
803
|
+
}, Ye = ({
|
|
804
|
+
codeContent: i,
|
|
805
|
+
fileName: t = "code.js",
|
|
806
|
+
language: r = "javascript",
|
|
807
|
+
readOnly: n = !1
|
|
808
|
+
}) => {
|
|
809
|
+
const a = {
|
|
810
|
+
formConfig: {
|
|
811
|
+
codeContent: i,
|
|
812
|
+
fileName: t,
|
|
813
|
+
language: r
|
|
814
|
+
},
|
|
815
|
+
settings: {
|
|
816
|
+
readOnly: n
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
return /* @__PURE__ */ o.jsx(Y, { config: a });
|
|
820
|
+
}, Me = ({ fileUrls: i, rightPanel: t }) => {
|
|
821
|
+
const r = {
|
|
822
|
+
urlConfig: {
|
|
823
|
+
fileUrls: i
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
return /* @__PURE__ */ o.jsx(Y, { config: r, rightPanel: t });
|
|
827
|
+
}, Be = "1.0.0";
|
|
828
|
+
export {
|
|
829
|
+
Ve as Alert,
|
|
830
|
+
qe as Button,
|
|
831
|
+
Ne as CodeEditor,
|
|
832
|
+
Y as CodeEditorWrapper,
|
|
833
|
+
Oe as EditorLayout,
|
|
834
|
+
Pe as FileExplorer,
|
|
835
|
+
Ye as FormCodeEditor,
|
|
836
|
+
Ce as FormFileProvider,
|
|
837
|
+
Je as Splitter,
|
|
838
|
+
Ge as Tooltip,
|
|
839
|
+
Xe as Tree,
|
|
840
|
+
Me as URLCodeEditor,
|
|
841
|
+
ke as URLFileProvider,
|
|
842
|
+
Be as VERSION,
|
|
843
|
+
De as WorkflowCodeEditor,
|
|
844
|
+
Te as WorkflowFileProvider,
|
|
845
|
+
Se as createFileProvider,
|
|
846
|
+
_e as useFileManager
|
|
847
|
+
};
|