@floegence/floe-webapp-core 0.81.2 → 0.81.5
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/components/chat/blocks/SvgBlock.js +16 -10
- package/dist/components/editor/CodeEditor.d.ts +1 -2
- package/dist/components/editor/CodeEditor.js +8 -9
- package/dist/components/editor/languages.js +37 -37
- package/dist/components/editor/monacoEnvironment.js +5 -5
- package/dist/components/editor/monacoStandaloneRuntime.d.ts +1 -1
- package/dist/components/editor/monacoStandaloneRuntime.js +7 -7
- package/dist/components/icons/RemoteControlIcons.d.ts +10 -0
- package/dist/components/icons/RemoteControlIcons.js +104 -0
- package/dist/components/icons/index.d.ts +1 -0
- package/dist/full.js +679 -669
- package/dist/icons.js +98 -88
- package/dist/node_modules/.pnpm/dompurify@3.4.16/node_modules/dompurify/dist/purify.es.js +1480 -0
- package/dist/remote-pointer.js +81 -69
- package/dist/terminal/mockRuntime.js +118 -110
- package/package.json +3 -2
package/dist/remote-pointer.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
function
|
|
2
|
-
const { surface: l } = a, I = l.ownerDocument,
|
|
3
|
-
if (!
|
|
4
|
-
let o = null, f = null, u = null, p = null,
|
|
5
|
-
const g = /* @__PURE__ */ new Set(),
|
|
1
|
+
function F(a) {
|
|
2
|
+
const { surface: l } = a, I = l.ownerDocument, s = I.defaultView;
|
|
3
|
+
if (!s) throw new Error("Remote pointer requires an attached document");
|
|
4
|
+
let o = null, f = null, u = null, p = null, k = 0, z = !1, L = 0, M = 0, C = !1, H = !1, D = 0, b = !1;
|
|
5
|
+
const g = /* @__PURE__ */ new Set(), O = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map(), K = [], w = (e) => !H && a.isTargetValid(e), E = (e, t) => Math.hypot(e.clientX - t.clientX, e.clientY - t.clientY), v = (e) => ({
|
|
6
6
|
clientX: e.clientX,
|
|
7
7
|
clientY: e.clientY,
|
|
8
8
|
shiftKey: e.shiftKey,
|
|
@@ -12,64 +12,76 @@ function U(a) {
|
|
|
12
12
|
pointerType: "pointerType" in e ? String(e.pointerType) : "mouse"
|
|
13
13
|
});
|
|
14
14
|
function d(e, t, n, i = !1) {
|
|
15
|
-
const
|
|
16
|
-
e.addEventListener(t,
|
|
15
|
+
const c = n;
|
|
16
|
+
e.addEventListener(t, c, { capture: i, passive: !1 }), K.push(() => e.removeEventListener(t, c, i));
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function Y(e, t) {
|
|
19
19
|
const n = w(t) && a.sendPointer(e, t) !== !1;
|
|
20
20
|
if (n && e.kind === "move")
|
|
21
21
|
for (const i of h.values()) i.target === t && (i.command = { ...i.command, ...v(e) });
|
|
22
22
|
return n;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
24
|
+
function P() {
|
|
25
|
+
s.clearTimeout(M), M = 0, C && (C = !1, a.onHoldChange?.(null));
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
27
|
+
function _(e) {
|
|
28
|
+
O.delete(e), l.hasPointerCapture?.(e) && l.releasePointerCapture(e);
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
l.setPointerCapture?.(e),
|
|
30
|
+
function q(e) {
|
|
31
|
+
l.setPointerCapture?.(e), O.add(e);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
33
|
+
function y() {
|
|
34
|
+
L++, z = !1, k && s.cancelAnimationFrame(k), k = 0;
|
|
35
35
|
const e = f;
|
|
36
|
-
f = null, e && !
|
|
36
|
+
f = null, e && !Y(e.command, e.target) && r();
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
if (f && (f.target !== t || f.command.kind !== e.kind) &&
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
function x(e, t) {
|
|
39
|
+
if (f && (f.target !== t || f.command.kind !== e.kind) && y(), !!w(t)) {
|
|
40
|
+
if (e.kind === "scroll" && f?.command.kind === "scroll" && (e = { ...e, dx: f.command.dx + e.dx, dy: f.command.dy + e.dy }), f = { target: t, command: e }, e.kind === "move") {
|
|
41
|
+
if (!z) {
|
|
42
|
+
z = !0;
|
|
43
|
+
const n = L;
|
|
44
|
+
s.queueMicrotask(() => {
|
|
45
|
+
n === L && y();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!k) {
|
|
51
|
+
const n = D, i = s.requestAnimationFrame(() => {
|
|
52
|
+
n === D && k === i && y();
|
|
53
|
+
});
|
|
54
|
+
k = i;
|
|
55
|
+
}
|
|
44
56
|
}
|
|
45
57
|
}
|
|
46
|
-
function T(e, t, n, i,
|
|
58
|
+
function T(e, t, n, i, c = 1) {
|
|
47
59
|
const m = h.get(i);
|
|
48
60
|
if (!e && !m) return;
|
|
49
61
|
e || h.delete(i);
|
|
50
|
-
const
|
|
51
|
-
|
|
62
|
+
const U = { ...t, kind: e ? "down" : "up", button: i, clicks: c };
|
|
63
|
+
Y(U, n) && e && h.set(i, { target: n, command: U });
|
|
52
64
|
}
|
|
53
|
-
function
|
|
65
|
+
function X(e, t) {
|
|
54
66
|
const n = D;
|
|
55
67
|
return a.onActivate?.(e, t), n === D && w(t);
|
|
56
68
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
69
|
+
function A(e, t, n, i = 1) {
|
|
70
|
+
X(e, t) && (T(!0, e, t, n, i), T(!1, e, t, n, i));
|
|
59
71
|
}
|
|
60
72
|
function r() {
|
|
61
|
-
D++,
|
|
73
|
+
D++, L++, z = !1, P(), k && s.cancelAnimationFrame(k), k = 0;
|
|
62
74
|
const e = /* @__PURE__ */ new Set();
|
|
63
75
|
o && e.add(o.target), f && e.add(f.target), u !== null && e.add(u), f = null, o = null, u = null, p = null, b = g.size > 0;
|
|
64
76
|
for (const [t, n] of h)
|
|
65
77
|
e.add(n.target), T(!1, n.command, n.target, t);
|
|
66
78
|
for (const t of e) a.release(t);
|
|
67
|
-
for (const t of [...
|
|
79
|
+
for (const t of [...O]) _(t);
|
|
68
80
|
}
|
|
69
81
|
function S(e) {
|
|
70
|
-
g.delete(e),
|
|
82
|
+
g.delete(e), _(e), g.size || (b = !1);
|
|
71
83
|
}
|
|
72
|
-
function
|
|
84
|
+
function B(e) {
|
|
73
85
|
const t = o;
|
|
74
86
|
if (!t || t.id !== e.pointerId) return;
|
|
75
87
|
if (!w(t.target)) {
|
|
@@ -77,14 +89,14 @@ function U(a) {
|
|
|
77
89
|
return;
|
|
78
90
|
}
|
|
79
91
|
const n = v(e);
|
|
80
|
-
if ((t.mode === "pending" || t.mode === "hold") &&
|
|
92
|
+
if ((t.mode === "pending" || t.mode === "hold") && E(t.origin, n) > 8) {
|
|
81
93
|
const i = t.mode === "hold";
|
|
82
|
-
if (
|
|
94
|
+
if (P(), p = null, t.mode = i ? "drag" : "scroll", i && X(t.origin, t.target) && T(!0, t.origin, t.target, 0), o !== t) return;
|
|
83
95
|
}
|
|
84
96
|
if (t.mode === "scroll") {
|
|
85
|
-
const i = t.last,
|
|
86
|
-
(
|
|
87
|
-
} else t.mode === "drag" && (
|
|
97
|
+
const i = t.last, c = i.clientX - n.clientX, m = i.clientY - n.clientY;
|
|
98
|
+
(c || m) && x({ ...t.origin, kind: "scroll", dx: c, dy: m }, t.target), t.last = n;
|
|
99
|
+
} else t.mode === "drag" && (x({ ...n, kind: "move" }, t.target), t.last = n);
|
|
88
100
|
}
|
|
89
101
|
d(l, "pointerdown", (e) => {
|
|
90
102
|
const t = a.resolveTarget(e);
|
|
@@ -95,15 +107,15 @@ function U(a) {
|
|
|
95
107
|
r();
|
|
96
108
|
return;
|
|
97
109
|
}
|
|
98
|
-
(o || h.size) && r(),
|
|
110
|
+
(o || h.size) && r(), y(), u !== null && (a.release(u), u = null), b = !1, o = { id: e.pointerId, target: t, origin: n, last: n, mode: "pending" };
|
|
99
111
|
const i = o;
|
|
100
|
-
|
|
101
|
-
if (
|
|
112
|
+
M = s.setTimeout(() => {
|
|
113
|
+
if (M = 0, o === i) {
|
|
102
114
|
if (!w(t)) {
|
|
103
115
|
r();
|
|
104
116
|
return;
|
|
105
117
|
}
|
|
106
|
-
i.mode = "hold",
|
|
118
|
+
i.mode = "hold", C = !0, a.onHoldChange?.({ ...n, target: t });
|
|
107
119
|
}
|
|
108
120
|
}, 450);
|
|
109
121
|
} else {
|
|
@@ -111,14 +123,14 @@ function U(a) {
|
|
|
111
123
|
r();
|
|
112
124
|
return;
|
|
113
125
|
}
|
|
114
|
-
o && (o.id !== e.pointerId || o.target !== t) && r(),
|
|
115
|
-
const i = e.button === 0 && p?.target === t &&
|
|
116
|
-
|
|
126
|
+
o && (o.id !== e.pointerId || o.target !== t) && r(), y(), u !== null && (a.release(u), u = null), o = { id: e.pointerId, target: t, origin: n, last: n, mode: "direct" };
|
|
127
|
+
const i = e.button === 0 && p?.target === t && s.performance.now() - p.time <= 350 && E(p.position, n) <= 16;
|
|
128
|
+
X(n, t) && T(!0, n, t, e.button, Math.max(1, e.detail, i ? 2 : 1));
|
|
117
129
|
}
|
|
118
|
-
|
|
130
|
+
q(e.pointerId), e.pointerType === "touch" && e.preventDefault();
|
|
119
131
|
}), d(l, "pointermove", (e) => {
|
|
120
132
|
if (e.pointerType === "touch") {
|
|
121
|
-
|
|
133
|
+
B(e);
|
|
122
134
|
return;
|
|
123
135
|
}
|
|
124
136
|
if (b || g.size) return;
|
|
@@ -130,35 +142,35 @@ function U(a) {
|
|
|
130
142
|
const n = v(e);
|
|
131
143
|
if (o) {
|
|
132
144
|
o.last = n;
|
|
133
|
-
for (const [i,
|
|
134
|
-
const m = !!(e.buttons &
|
|
135
|
-
m !== h.has(i) && (
|
|
145
|
+
for (const [i, c] of [[0, 1], [1, 4], [2, 2], [3, 8], [4, 16]]) {
|
|
146
|
+
const m = !!(e.buttons & c);
|
|
147
|
+
m !== h.has(i) && (y(), T(m, n, t, i));
|
|
136
148
|
}
|
|
137
149
|
}
|
|
138
|
-
|
|
150
|
+
x({ ...n, kind: "move" }, t);
|
|
139
151
|
}), d(l, "pointerup", (e) => {
|
|
140
152
|
const t = o;
|
|
141
153
|
if (t?.id === e.pointerId && !b)
|
|
142
154
|
if (!w(t.target)) r();
|
|
143
155
|
else if (e.pointerType === "touch") {
|
|
144
|
-
|
|
156
|
+
B(e), P();
|
|
145
157
|
const n = v(e);
|
|
146
158
|
if (t.mode === "pending") {
|
|
147
|
-
const i =
|
|
148
|
-
|
|
149
|
-
} else t.mode === "hold" ? (p = null,
|
|
159
|
+
const i = s.performance.now(), c = p?.target === t.target && i - p.time <= 350 && E(p.position, n) <= 16;
|
|
160
|
+
A(n, t.target, 0, c ? 2 : 1), p = c ? null : { target: t.target, position: n, time: i };
|
|
161
|
+
} else t.mode === "hold" ? (p = null, A(n, t.target, 2)) : (y(), t.mode === "drag" && T(!1, n, t.target, 0));
|
|
150
162
|
a.release(t.target), o = null;
|
|
151
163
|
} else {
|
|
152
|
-
f?.command.kind === "move" && (f.command = { ...v(e), kind: "move" }),
|
|
164
|
+
f?.command.kind === "move" && (f.command = { ...v(e), kind: "move" }), y();
|
|
153
165
|
const n = h.get(e.button)?.command;
|
|
154
166
|
for (const i of [...h.keys()]) T(!1, v(e), t.target, i, n && "clicks" in n ? n.clicks : 1);
|
|
155
|
-
p = e.button === 0 && n && "clicks" in n && n.clicks === 1 &&
|
|
167
|
+
p = e.button === 0 && n && "clicks" in n && n.clicks === 1 && E(t.origin, v(e)) <= 8 ? { target: t.target, position: v(e), time: s.performance.now() } : null, h.size || (o = null);
|
|
156
168
|
}
|
|
157
169
|
(!o || o.id !== e.pointerId) && S(e.pointerId);
|
|
158
170
|
}), d(l, "pointercancel", (e) => {
|
|
159
171
|
r(), S(e.pointerId);
|
|
160
172
|
}), d(l, "lostpointercapture", (e) => {
|
|
161
|
-
|
|
173
|
+
O.has(e.pointerId) && (r(), S(e.pointerId));
|
|
162
174
|
}), d(I, "pointerup", (e) => {
|
|
163
175
|
o?.id !== e.pointerId && S(e.pointerId);
|
|
164
176
|
}), d(I, "pointercancel", (e) => S(e.pointerId)), d(I, "pointerdown", (e) => {
|
|
@@ -166,33 +178,33 @@ function U(a) {
|
|
|
166
178
|
}, !0), d(l, "wheel", (e) => {
|
|
167
179
|
const t = a.resolveTarget(e);
|
|
168
180
|
if (t === null || !w(t) || (e.preventDefault(), o || g.size)) return;
|
|
169
|
-
p = null, u !== null && u !== t && (
|
|
170
|
-
const n = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? l.clientWidth ||
|
|
171
|
-
Number.isFinite(
|
|
181
|
+
p = null, u !== null && u !== t && (y(), a.release(u)), u = t;
|
|
182
|
+
const n = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? l.clientWidth || s.innerWidth : 1, i = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? l.clientHeight || s.innerHeight : 1, c = e.deltaX * n, m = e.deltaY * i;
|
|
183
|
+
Number.isFinite(c) && Number.isFinite(m) && (c || m) && x({ ...v(e), kind: "scroll", dx: c, dy: m }, t);
|
|
172
184
|
});
|
|
173
185
|
for (const e of ["mousedown", "mouseup", "click", "dblclick", "contextmenu", "dragstart", "selectstart"])
|
|
174
186
|
d(l, e, (t) => {
|
|
175
187
|
a.resolveTarget(t) !== null && t.preventDefault();
|
|
176
188
|
});
|
|
177
|
-
for (const e of ["blur", "pagehide", "resize", "orientationchange"]) d(
|
|
189
|
+
for (const e of ["blur", "pagehide", "resize", "orientationchange"]) d(s, e, r);
|
|
178
190
|
if (d(I, "visibilitychange", () => {
|
|
179
191
|
I.hidden && r();
|
|
180
|
-
}), d(
|
|
192
|
+
}), d(s, "scroll", r, !0), s.visualViewport && (d(s.visualViewport, "resize", r), d(s.visualViewport, "scroll", r)), typeof ResizeObserver < "u") {
|
|
181
193
|
let e = `${l.clientWidth}:${l.clientHeight}`;
|
|
182
194
|
const t = new ResizeObserver(() => {
|
|
183
195
|
const n = `${l.clientWidth}:${l.clientHeight}`;
|
|
184
196
|
n !== e && (e = n, r());
|
|
185
197
|
});
|
|
186
|
-
t.observe(l),
|
|
198
|
+
t.observe(l), K.push(() => t.disconnect());
|
|
187
199
|
}
|
|
188
|
-
return { flush:
|
|
189
|
-
if (!
|
|
190
|
-
r(),
|
|
191
|
-
for (const e of
|
|
200
|
+
return { flush: y, reset: r, dispose() {
|
|
201
|
+
if (!H) {
|
|
202
|
+
r(), H = !0;
|
|
203
|
+
for (const e of K) e();
|
|
192
204
|
g.clear();
|
|
193
205
|
}
|
|
194
206
|
} };
|
|
195
207
|
}
|
|
196
208
|
export {
|
|
197
|
-
|
|
209
|
+
F as createRemotePointer
|
|
198
210
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { normalizeTerminalWorkspaceProfile as
|
|
2
|
-
const
|
|
1
|
+
import { normalizeTerminalWorkspaceProfile as z } from "./workspaceProfile.js";
|
|
2
|
+
const A = {
|
|
3
3
|
"README.md": `# Floe Webapp
|
|
4
4
|
Terminal-first demo workspace with a mobile keyboard.`,
|
|
5
5
|
"package.json": `{
|
|
@@ -26,8 +26,8 @@ VITE_FLOE_ENDPOINT_ID=demo-endpoint`,
|
|
|
26
26
|
"scripts/dev.mjs": `import { spawn } from 'node:child_process';
|
|
27
27
|
|
|
28
28
|
spawn('pnpm', ['--filter', '@floegence/floe-webapp-demo', 'dev'], { stdio: 'inherit' });`
|
|
29
|
-
},
|
|
30
|
-
const
|
|
29
|
+
}, G = (i, n) => {
|
|
30
|
+
const r = z(n?.profile), a = n?.resolveNow ?? (() => (/* @__PURE__ */ new Date()).toString()), e = i.trim();
|
|
31
31
|
if (!e)
|
|
32
32
|
return {
|
|
33
33
|
clear: !1,
|
|
@@ -39,28 +39,28 @@ spawn('pnpm', ['--filter', '@floegence/floe-webapp-demo', 'dev'], { stdio: 'inhe
|
|
|
39
39
|
"Available commands:",
|
|
40
40
|
'pwd, ls, ls -la, cat <file>, less <file>, head -n <count> <file>, tail -n <count> <file>, wc -l|-w|-c <file>, mkdir -p <dir>, touch <file>, chmod <mode> <target>, clear, date, echo <text>, echo "$PATH", echo "$SHELL"',
|
|
41
41
|
"git status, git diff, git log --oneline -10, git add ., git checkout -b <branch>, git commit -m <message>",
|
|
42
|
-
`pnpm ${
|
|
42
|
+
`pnpm ${r.scripts.join(", pnpm ")}`,
|
|
43
43
|
"find . -name <pattern>, grep -R <pattern> src/, grep -n <pattern> <file>, grep -i <pattern> <file>, sort <file>, cut <options> <file>, uname -a, vim <file>, sed -n <range> <file>, awk <program> <file>",
|
|
44
44
|
"curl -I|-L <url>, tar -czf|-xzf|-tf <archive>, ssh <host>, scp <src> <dest>"
|
|
45
45
|
].join(`
|
|
46
46
|
`)
|
|
47
47
|
);
|
|
48
48
|
if (e === "pwd")
|
|
49
|
-
return t(
|
|
49
|
+
return t(r.cwd);
|
|
50
50
|
if (e === "ls" || e === "ls -la") {
|
|
51
|
-
const
|
|
51
|
+
const s = [...r.directories, ...r.files];
|
|
52
52
|
return t(
|
|
53
|
-
e === "ls" ?
|
|
54
|
-
...
|
|
55
|
-
...
|
|
53
|
+
e === "ls" ? s.join(" ") : [
|
|
54
|
+
...r.directories.map((o) => `drwxr-xr-x ${o}`),
|
|
55
|
+
...r.files.map((o) => `-rw-r--r-- ${o}`)
|
|
56
56
|
].join(`
|
|
57
57
|
`)
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
if (e.startsWith("ls ")) {
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
return t(
|
|
61
|
+
const s = e.slice(3).trim().replace(/\/$/, "");
|
|
62
|
+
if (r.directories.includes(s))
|
|
63
|
+
return t(s === "packages" ? "boot core init protocol" : s === "apps" ? "demo" : s === "src" ? "app.ts widgets terminal components" : `${s}/`);
|
|
64
64
|
}
|
|
65
65
|
if (e === "clear")
|
|
66
66
|
return {
|
|
@@ -68,7 +68,7 @@ spawn('pnpm', ['--filter', '@floegence/floe-webapp-demo', 'dev'], { stdio: 'inhe
|
|
|
68
68
|
lines: []
|
|
69
69
|
};
|
|
70
70
|
if (e === "date")
|
|
71
|
-
return t(
|
|
71
|
+
return t(a());
|
|
72
72
|
if (e === 'echo "$PATH"')
|
|
73
73
|
return t("/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin");
|
|
74
74
|
if (e === 'echo "$SHELL"')
|
|
@@ -93,97 +93,98 @@ c942cb5 add terminal-first mobile keyboard
|
|
|
93
93
|
37fa316 release 0.35.7`);
|
|
94
94
|
if (e === "git add .")
|
|
95
95
|
return t("staged tracked changes");
|
|
96
|
-
const f = e.match(/^git checkout -b\s+(
|
|
96
|
+
const f = e.match(/^git checkout -b\s+(\S.*)$/);
|
|
97
97
|
if (f)
|
|
98
98
|
return t(`Switched to a new branch '${f[1]}'`);
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
101
|
-
return t(`[main abc1234] ${
|
|
99
|
+
const u = e.match(/^git commit -m\s+"(.+)"$/);
|
|
100
|
+
if (u)
|
|
101
|
+
return t(`[main abc1234] ${u[1]}
|
|
102
102
|
3 files changed, 42 insertions(+), 8 deletions(-)`);
|
|
103
|
-
const d = e.match(/^cat\s+(
|
|
103
|
+
const d = e.match(/^cat\s+(\S.*)$/);
|
|
104
104
|
if (d) {
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
107
|
-
return t(
|
|
105
|
+
const s = p(r.files, d[1] ?? "");
|
|
106
|
+
if (s)
|
|
107
|
+
return t(s);
|
|
108
108
|
}
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
const
|
|
109
|
+
const S = e.match(/^vim\s+(\S.*)$/);
|
|
110
|
+
if (S) {
|
|
111
|
+
const s = m(S[1] ?? ""), o = p(r.files, s);
|
|
112
112
|
if (o)
|
|
113
|
-
return t(
|
|
113
|
+
return t(_(s, o));
|
|
114
114
|
}
|
|
115
115
|
const $ = e.match(/^pnpm\s+([a-z0-9:-]+)$/i);
|
|
116
|
-
if ($ &&
|
|
116
|
+
if ($ && r.scripts.includes($[1] ?? ""))
|
|
117
117
|
return t(`> pnpm ${$[1]}
|
|
118
118
|
completed mock run for script '${$[1]}'`);
|
|
119
|
-
if (e.match(/^find \. -name\s+(
|
|
119
|
+
if (e.match(/^find \. -name\s+(\S.*)$/))
|
|
120
120
|
return t(["./README.md", "./packages/core/src/terminal/suggestionEngine.ts"].join(`
|
|
121
121
|
`));
|
|
122
|
-
|
|
122
|
+
const j = e.match(/^grep -R\s+(\S.*)$/)?.[1], L = j ? C(j) : null;
|
|
123
|
+
if (L && ["src", "src/"].includes(L[1]))
|
|
123
124
|
return t("src/terminal/suggestionEngine.ts:getTerminalSuggestions");
|
|
124
|
-
const b = e.match(/^grep\s+(-n|-i)\s+(
|
|
125
|
+
const b = e.match(/^grep\s+(-n|-i)\s+(\S+)\s+(\S.*)$/);
|
|
125
126
|
if (b) {
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
128
|
-
return t(
|
|
127
|
+
const s = b[1] ?? "", o = D(b[2] ?? ""), c = m(b[3] ?? ""), l = p(r.files, c);
|
|
128
|
+
if (l)
|
|
129
|
+
return t(P(l, c, o, s));
|
|
129
130
|
}
|
|
130
|
-
const v = e.match(/^less\s+(
|
|
131
|
+
const v = e.match(/^less\s+(\S.*)$/);
|
|
131
132
|
if (v) {
|
|
132
|
-
const
|
|
133
|
+
const s = m(v[1] ?? ""), o = p(r.files, s);
|
|
133
134
|
if (o)
|
|
134
135
|
return t(`${o}
|
|
135
136
|
(END)`);
|
|
136
137
|
}
|
|
137
|
-
const
|
|
138
|
-
if (L)
|
|
139
|
-
return t(`created directory ${l(L[1] ?? "")}`);
|
|
140
|
-
const N = e.match(/^touch\s+(.+)$/);
|
|
138
|
+
const N = e.match(/^mkdir\s+-p\s+(\S.*)$/);
|
|
141
139
|
if (N)
|
|
142
|
-
return t(`
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
140
|
+
return t(`created directory ${m(N[1] ?? "")}`);
|
|
141
|
+
const T = e.match(/^touch\s+(\S.*)$/);
|
|
142
|
+
if (T)
|
|
143
|
+
return t(`updated timestamp for ${m(T[1] ?? "")}`);
|
|
144
|
+
const w = e.match(/^chmod\s+(\S+)\s+(\S.*)$/);
|
|
145
|
+
if (w)
|
|
145
146
|
return t(
|
|
146
|
-
`mode ${
|
|
147
|
+
`mode ${w[1] ?? ""} applied to ${m(w[2] ?? "")}`
|
|
147
148
|
);
|
|
148
|
-
const h = e.match(/^head(?:\s+-n\s+(\d+))?(?:\s+-c\s+(\d+))?\s+(
|
|
149
|
+
const h = e.match(/^head(?:\s+-n\s+(\d+))?(?:\s+-c\s+(\d+))?\s+(\S.*)$/);
|
|
149
150
|
if (h) {
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
151
|
+
const s = Number(h[1] ?? 10), o = h[2] ? Number(h[2]) : null, c = m(h[3] ?? ""), l = p(r.files, c);
|
|
152
|
+
if (l)
|
|
152
153
|
return t(
|
|
153
|
-
o === null ?
|
|
154
|
+
o === null ? R(l, s) : l.slice(0, Math.max(0, o))
|
|
154
155
|
);
|
|
155
156
|
}
|
|
156
|
-
const g = e.match(/^tail(?:\s+-n\s+(\d+))?(?:\s+-c\s+(\d+))?\s+(
|
|
157
|
+
const g = e.match(/^tail(?:\s+-n\s+(\d+))?(?:\s+-c\s+(\d+))?\s+(\S.*)$/);
|
|
157
158
|
if (g) {
|
|
158
|
-
const
|
|
159
|
-
if (
|
|
159
|
+
const s = Number(g[1] ?? 10), o = g[2] ? Number(g[2]) : null, c = m(g[3] ?? ""), l = p(r.files, c);
|
|
160
|
+
if (l)
|
|
160
161
|
return t(
|
|
161
|
-
o === null ?
|
|
162
|
+
o === null ? W(l, s) : l.slice(Math.max(0, l.length - Math.max(0, o)))
|
|
162
163
|
);
|
|
163
164
|
}
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
166
|
-
const
|
|
165
|
+
const M = e.match(/^wc\s+(-[lwc])\s+(\S.*)$/);
|
|
166
|
+
if (M) {
|
|
167
|
+
const s = M[1] ?? "", o = m(M[2] ?? ""), c = p(r.files, o);
|
|
167
168
|
if (c)
|
|
168
|
-
return t(
|
|
169
|
+
return t(O(c, o, s));
|
|
169
170
|
}
|
|
170
|
-
const x = e.match(/^sort(?:\s+(-u|-r))?\s+(
|
|
171
|
+
const x = e.match(/^sort(?:\s+(-u|-r))?\s+(\S.*)$/);
|
|
171
172
|
if (x) {
|
|
172
|
-
const
|
|
173
|
+
const s = x[1] ?? "", o = m(x[2] ?? ""), c = p(r.files, o);
|
|
173
174
|
if (c)
|
|
174
|
-
return t(
|
|
175
|
+
return t(I(c, s));
|
|
175
176
|
}
|
|
176
|
-
const
|
|
177
|
+
const y = e.match(/^cut\s+(\S.*)$/)?.[1], E = y ? C(y) : null;
|
|
177
178
|
if (E) {
|
|
178
|
-
const
|
|
179
|
+
const s = E[0], o = m(E[1]), c = p(r.files, o);
|
|
179
180
|
if (c)
|
|
180
|
-
return t(
|
|
181
|
+
return t(B(c, s));
|
|
181
182
|
}
|
|
182
|
-
const k = e.match(/^sed -n '(\d+),(\d+)p'\s+(
|
|
183
|
+
const k = e.match(/^sed -n '(\d+),(\d+)p'\s+(\S.*)$/);
|
|
183
184
|
if (k) {
|
|
184
|
-
const
|
|
185
|
-
if (
|
|
186
|
-
return t(
|
|
185
|
+
const s = Number(k[1] ?? 1), o = Number(k[2] ?? s), c = m(k[3] ?? ""), l = p(r.files, c);
|
|
186
|
+
if (l)
|
|
187
|
+
return t(F(l, s, o));
|
|
187
188
|
}
|
|
188
189
|
return e === "sed -E 's/floe/Floe/g' README.md" ? t(`# Floe Webapp
|
|
189
190
|
Terminal-first demo workspace with a mobile keyboard.`) : e === "awk '{print $1}' package.json" ? t(["{", '"name":', '"scripts":', '"dev":', '"build":', "}", "}"].join(`
|
|
@@ -210,78 +211,85 @@ Last login: Tue Mar 17 22:00:00 2026`) : e === "ssh -p 22 user@example.com" ? t(
|
|
|
210
211
|
]
|
|
211
212
|
};
|
|
212
213
|
};
|
|
213
|
-
function t(
|
|
214
|
+
function t(i) {
|
|
214
215
|
return {
|
|
215
216
|
clear: !1,
|
|
216
217
|
lines: [
|
|
217
218
|
{
|
|
218
219
|
type: "output",
|
|
219
|
-
content:
|
|
220
|
+
content: i
|
|
220
221
|
}
|
|
221
222
|
]
|
|
222
223
|
};
|
|
223
224
|
}
|
|
224
|
-
function p(
|
|
225
|
-
const
|
|
226
|
-
return !
|
|
225
|
+
function p(i, n) {
|
|
226
|
+
const r = m(n);
|
|
227
|
+
return !r || !i.includes(r) ? null : A[r] ?? `// Mock contents for ${r}
|
|
227
228
|
// Generated by the shared terminal runtime.`;
|
|
228
229
|
}
|
|
229
|
-
function
|
|
230
|
-
return
|
|
230
|
+
function m(i) {
|
|
231
|
+
return i.trim().replace(/\/$/, "");
|
|
231
232
|
}
|
|
232
|
-
function
|
|
233
|
-
const
|
|
234
|
-
return
|
|
233
|
+
function D(i) {
|
|
234
|
+
const n = i.trim();
|
|
235
|
+
return n.startsWith('"') && n.endsWith('"') || n.startsWith("'") && n.endsWith("'") ? n.slice(1, -1) : n;
|
|
235
236
|
}
|
|
236
|
-
function
|
|
237
|
-
return
|
|
238
|
-
`).slice(0, Math.max(0,
|
|
237
|
+
function R(i, n) {
|
|
238
|
+
return i.split(`
|
|
239
|
+
`).slice(0, Math.max(0, n)).join(`
|
|
239
240
|
`);
|
|
240
241
|
}
|
|
241
|
-
function
|
|
242
|
-
return
|
|
243
|
-
`).slice(-Math.max(0,
|
|
242
|
+
function W(i, n) {
|
|
243
|
+
return i.split(`
|
|
244
|
+
`).slice(-Math.max(0, n)).join(`
|
|
244
245
|
`);
|
|
245
246
|
}
|
|
246
|
-
function
|
|
247
|
-
return
|
|
248
|
-
`).slice(Math.max(0,
|
|
247
|
+
function F(i, n, r) {
|
|
248
|
+
return i.split(`
|
|
249
|
+
`).slice(Math.max(0, n - 1), Math.max(n - 1, r)).join(`
|
|
249
250
|
`);
|
|
250
251
|
}
|
|
251
|
-
function
|
|
252
|
-
return `"${
|
|
253
|
-
`).length}L, ${
|
|
252
|
+
function _(i, n) {
|
|
253
|
+
return `"${i}" ${n.split(`
|
|
254
|
+
`).length}L, ${n.length}B
|
|
254
255
|
~
|
|
255
|
-
Mock vim session opened for ${
|
|
256
|
+
Mock vim session opened for ${i}`;
|
|
256
257
|
}
|
|
257
|
-
function
|
|
258
|
-
return
|
|
259
|
-
`).length} ${
|
|
258
|
+
function O(i, n, r) {
|
|
259
|
+
return r === "-l" ? `${i.split(`
|
|
260
|
+
`).length} ${n}` : r === "-w" ? `${i.trim().split(/\s+/).filter(Boolean).length} ${n}` : `${i.length} ${n}`;
|
|
260
261
|
}
|
|
261
|
-
function
|
|
262
|
-
if (!
|
|
263
|
-
return `${
|
|
264
|
-
const e =
|
|
265
|
-
return
|
|
266
|
-
`).map((
|
|
267
|
-
({ line:
|
|
268
|
-
).map(({ line:
|
|
269
|
-
`) || `${
|
|
262
|
+
function P(i, n, r, a) {
|
|
263
|
+
if (!r)
|
|
264
|
+
return `${n}: pattern is empty`;
|
|
265
|
+
const e = a === "-i" ? r.toLowerCase() : r;
|
|
266
|
+
return i.split(`
|
|
267
|
+
`).map((u, d) => ({ line: u, index: d })).filter(
|
|
268
|
+
({ line: u }) => (a === "-i" ? u.toLowerCase() : u).includes(e)
|
|
269
|
+
).map(({ line: u, index: d }) => a === "-n" ? `${d + 1}:${u}` : u).join(`
|
|
270
|
+
`) || `${n}: no matches`;
|
|
270
271
|
}
|
|
271
|
-
function
|
|
272
|
-
const
|
|
272
|
+
function I(i, n) {
|
|
273
|
+
const a = [...i.split(`
|
|
273
274
|
`)].sort((e, f) => e.localeCompare(f));
|
|
274
|
-
return
|
|
275
|
-
`) :
|
|
276
|
-
`) :
|
|
275
|
+
return n === "-u" ? [...new Set(a)].join(`
|
|
276
|
+
`) : n === "-r" ? a.reverse().join(`
|
|
277
|
+
`) : a.join(`
|
|
277
278
|
`);
|
|
278
279
|
}
|
|
279
|
-
function
|
|
280
|
-
const
|
|
281
|
-
return
|
|
282
|
-
`).map((
|
|
280
|
+
function B(i, n) {
|
|
281
|
+
const r = n.match(/-d\s+"([^"]+)"/), a = n.match(/-f\s+(\d+)/), e = r?.[1] ?? " ", f = Math.max(1, Number(a?.[1] ?? 1)) - 1;
|
|
282
|
+
return i.split(`
|
|
283
|
+
`).map((u) => u.split(e)[f] ?? "").join(`
|
|
283
284
|
`);
|
|
284
285
|
}
|
|
286
|
+
function C(i) {
|
|
287
|
+
let n = i.length - 1;
|
|
288
|
+
for (; n >= 0 && !/\s/.test(i[n]); ) n -= 1;
|
|
289
|
+
if (n < 0) return null;
|
|
290
|
+
const r = i.slice(n + 1), a = i.slice(0, n).trimEnd();
|
|
291
|
+
return a ? [a, r] : null;
|
|
292
|
+
}
|
|
285
293
|
export {
|
|
286
|
-
|
|
294
|
+
G as runTerminalMockCommand
|
|
287
295
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floegence/floe-webapp-core",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -152,9 +152,10 @@
|
|
|
152
152
|
"dependencies": {
|
|
153
153
|
"clsx": "^2.1.1",
|
|
154
154
|
"diff": "^8.0.4",
|
|
155
|
+
"dompurify": "^3.4.16",
|
|
155
156
|
"marked": "^17.0.6",
|
|
156
157
|
"mermaid": "^11.17.2",
|
|
157
|
-
"monaco-editor": "^0.
|
|
158
|
+
"monaco-editor": "^0.57.0",
|
|
158
159
|
"pdfjs-dist": "6.3.289",
|
|
159
160
|
"shiki": "^3.23.0",
|
|
160
161
|
"solid-motionone": "^1.0.4",
|