@omg-dev/app 0.6.209 → 0.6.211

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omg-dev/app",
3
- "version": "0.6.209",
3
+ "version": "0.6.211",
4
4
  "description": "The full OMG application surface for React hosts.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://omg.dev",
@@ -29,8 +29,8 @@
29
29
  "@chenglou/pretext": "^0.0.8",
30
30
  "@novnc/novnc": "^1.7.0",
31
31
  "@number-flow/react": "^0.6.2",
32
- "@omg-dev/client": "0.6.209",
33
- "@omg-dev/protocol": "0.6.209",
32
+ "@omg-dev/client": "0.6.211",
33
+ "@omg-dev/protocol": "0.6.211",
34
34
  "@pierre/diffs": "^1.3.1",
35
35
  "@pierre/trees": "1.0.0-beta.6",
36
36
  "@streamdown/cjk": "^1.0.3",
@@ -1,234 +0,0 @@
1
- import { jsx as i, jsxs as g, Fragment as J } from "react/jsx-runtime";
2
- import { useState as N, useRef as y, useEffect as S, useLayoutEffect as V, useCallback as W } from "react";
3
- import { createPortal as q } from "react-dom";
4
- import { R as G, a as Q, d as A } from "./computer-pointer-C3VB2laK.js";
5
- import { F as Z, a9 as $, X as ee, L as te, aa as ne } from "./embedded-DYhLh9dW.js";
6
- /**
7
- * @license lucide-react v0.577.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */
12
- const se = [
13
- ["rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2", key: "1w4ew1" }],
14
- ["path", { d: "M7 11V7a5 5 0 0 1 10 0v4", key: "fwvmzm" }]
15
- ], re = Z("lock", se), oe = "/api/computer/kiosk";
16
- function ie(n, o = "expo.dev") {
17
- try {
18
- return n?.url && new URL(n.url).hostname.replace(/^www\./, "") || o;
19
- } catch {
20
- return o;
21
- }
22
- }
23
- function ce(n, o) {
24
- if (!n.open || !n.rect || !n.screen || n.rect.width <= 0 || o <= 0) return null;
25
- const l = o / n.rect.width;
26
- return {
27
- scale: l,
28
- left: -n.rect.x * l,
29
- top: -n.rect.y * l,
30
- width: n.screen.width * l,
31
- height: n.screen.height * l,
32
- pageHeight: n.rect.height * l
33
- };
34
- }
35
- function le(n, o, l, f) {
36
- if (n.editing) return !0;
37
- const k = l / o, E = f / o;
38
- return (n.inputs ?? []).some((u) => k >= u.x && k <= u.x + u.width && E >= u.y && E <= u.y + u.height);
39
- }
40
- function ae(n) {
41
- if (n === `
42
- ` || n === "\r") return 65293;
43
- const o = n.codePointAt(0) ?? 0;
44
- return o < 256 ? o : 16777216 + o;
45
- }
46
- const j = {
47
- Enter: 65293,
48
- Backspace: 65288,
49
- Tab: 65289,
50
- Escape: 65307,
51
- ArrowLeft: 65361,
52
- ArrowUp: 65362,
53
- ArrowRight: 65363,
54
- ArrowDown: 65364
55
- }, I = 80, b = `
56
- `.repeat(64), F = {
57
- signup: "Sign up for Expo",
58
- login: "Sign in to Expo"
59
- };
60
- function ve({ mode: n, onClose: o, onOpenComputer: l }) {
61
- const [f, k] = N(null), [E, u] = N(!1), [H, R] = N(!1), [K, X] = N(0), C = y(null), x = y(null), M = y(null), m = y(null), T = y(null);
62
- T.current = f, S(() => {
63
- let e = !0;
64
- const t = async () => {
65
- try {
66
- const a = await ne(oe);
67
- if (a.ok && e) {
68
- const w = await a.json();
69
- k((p) => JSON.stringify(p) === JSON.stringify(w) ? p : w);
70
- }
71
- } catch {
72
- }
73
- };
74
- t();
75
- const s = setInterval(t, 700);
76
- return () => {
77
- e = !1, clearInterval(s);
78
- };
79
- }, []), V(() => {
80
- const e = C.current;
81
- if (!e) return;
82
- const t = () => X(e.clientWidth);
83
- if (t(), typeof ResizeObserver > "u") return;
84
- const s = new ResizeObserver(t);
85
- return s.observe(e), () => s.disconnect();
86
- }, []);
87
- const Y = !!f?.open;
88
- S(() => {
89
- if (!Y || m.current || !x.current) return;
90
- let e = !1;
91
- return (async () => {
92
- try {
93
- const t = await $("/api/computer");
94
- if (e || !x.current) {
95
- t.close();
96
- return;
97
- }
98
- const s = new G(x.current, new Q(t), { shared: !0 });
99
- s.scaleViewport = !0, s.background = "transparent", s.viewOnly = !1, s.addEventListener("connect", () => {
100
- u(!0), R(!1);
101
- }), s.addEventListener("disconnect", () => {
102
- m.current = null, u(!1), R(!0);
103
- }), m.current = s;
104
- } catch {
105
- R(!0);
106
- }
107
- })(), () => {
108
- e = !0;
109
- };
110
- }, [Y]), S(() => () => {
111
- try {
112
- m.current?.disconnect();
113
- } catch {
114
- }
115
- m.current = null;
116
- }, []);
117
- const d = f ? ce(f, K) : null, O = W(() => x.current?.querySelector("canvas") ?? null, []);
118
- S(() => {
119
- const e = C.current;
120
- if (!e) return;
121
- let t = null, s = 0;
122
- const a = (c) => {
123
- c.preventDefault(), c.stopPropagation();
124
- const r = c.touches[0];
125
- if (!r || c.touches.length !== 1) {
126
- t = null;
127
- return;
128
- }
129
- t = { x: r.clientX, y: r.clientY, at: Date.now(), lastY: r.clientY, moved: !1 }, s = 0;
130
- }, w = (c) => {
131
- c.preventDefault(), c.stopPropagation();
132
- const r = c.touches[0], v = O();
133
- if (!(!t || !r || !v) && (Math.hypot(r.clientX - t.x, r.clientY - t.y) > 8 && (t.moved = !0), !!t.moved))
134
- for (s += t.lastY - r.clientY, t.lastY = r.clientY; Math.abs(s) >= I; ) {
135
- const h = s > 0;
136
- s += h ? -I : I, v.dispatchEvent(new WheelEvent("wheel", { bubbles: !0, cancelable: !0, clientX: r.clientX, clientY: r.clientY, deltaY: h ? 60 : -60 }));
137
- }
138
- }, p = (c) => {
139
- c.preventDefault(), c.stopPropagation();
140
- const r = t;
141
- t = null;
142
- const v = O();
143
- if (!r || r.moved || !v || Date.now() - r.at > 600) return;
144
- const h = { x: r.x, y: r.y };
145
- A(v, h, "mousemove", 0), A(v, h, "mousedown", 1, 0), A(v, h, "mouseup", 0, 0);
146
- const D = T.current, P = e.getBoundingClientRect(), L = M.current;
147
- if (!L || !D?.rect) return;
148
- const U = P.width / D.rect.width;
149
- le(D, U, h.x - P.left, h.y - P.top) ? (L.value = b, L.focus({ preventScroll: !0 })) : L.blur();
150
- };
151
- return e.addEventListener("touchstart", a, { passive: !1, capture: !0 }), e.addEventListener("touchmove", w, { passive: !1, capture: !0 }), e.addEventListener("touchend", p, { passive: !1, capture: !0 }), e.addEventListener("touchcancel", p, { passive: !1, capture: !0 }), () => {
152
- e.removeEventListener("touchstart", a, { capture: !0 }), e.removeEventListener("touchmove", w, { capture: !0 }), e.removeEventListener("touchend", p, { capture: !0 }), e.removeEventListener("touchcancel", p, { capture: !0 });
153
- };
154
- }, [O]);
155
- const z = (e) => {
156
- const t = m.current;
157
- t && (t.sendKey(e, null, !0), t.sendKey(e, null, !1));
158
- }, _ = ie(f), B = Y && E && !!d;
159
- return q(
160
- /* @__PURE__ */ i("div", { className: "fixed inset-0 z-[100] flex items-end justify-center bg-black/40 sm:items-center", "data-testid": "expo-signin-sheet-backdrop", children: /* @__PURE__ */ g(
161
- "div",
162
- {
163
- role: "dialog",
164
- "aria-label": F[n],
165
- "data-testid": "expo-signin-sheet",
166
- className: "flex h-[92dvh] w-full flex-col overflow-hidden rounded-t-2xl border bg-background shadow-2xl sm:h-[min(844px,92dvh)] sm:w-[390px] sm:rounded-2xl",
167
- children: [
168
- /* @__PURE__ */ g("div", { className: "flex shrink-0 items-center gap-2 border-b px-3 py-2", children: [
169
- /* @__PURE__ */ g("div", { className: "min-w-0 flex-1", children: [
170
- /* @__PURE__ */ i("p", { className: "truncate text-sm font-semibold", "data-testid": "expo-signin-sheet-title", children: F[n] }),
171
- /* @__PURE__ */ g("p", { className: "flex items-center gap-1 text-xs text-muted-foreground", "data-testid": "expo-signin-sheet-host", children: [
172
- /* @__PURE__ */ i(re, { className: "size-3", "aria-hidden": !0 }),
173
- _
174
- ] })
175
- ] }),
176
- /* @__PURE__ */ i(
177
- "button",
178
- {
179
- type: "button",
180
- className: "inline-flex size-8 items-center justify-center rounded-full text-muted-foreground hover:bg-muted",
181
- onClick: o,
182
- "aria-label": "Cancel and close",
183
- "data-testid": "expo-signin-sheet-close",
184
- children: /* @__PURE__ */ i(ee, { className: "size-5", "aria-hidden": !0 })
185
- }
186
- )
187
- ] }),
188
- /* @__PURE__ */ g("div", { ref: C, className: "relative min-h-0 flex-1 touch-none select-none overflow-hidden bg-white", "data-testid": "expo-signin-sheet-view", children: [
189
- /* @__PURE__ */ i("div", { className: "absolute left-0 top-0 overflow-hidden", style: d ? { width: "100%", height: d.pageHeight } : { width: 0, height: 0 }, children: /* @__PURE__ */ i("div", { ref: x, className: "absolute", style: d ? { left: d.left, top: d.top, width: d.width, height: d.height } : { left: 0, top: 0, width: 1, height: 1 } }) }),
190
- B ? null : /* @__PURE__ */ i("div", { className: "absolute inset-0 flex items-center justify-center bg-background", "data-testid": "expo-signin-sheet-loading", children: /* @__PURE__ */ i("span", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: H ? "Lost the connection to the Computer." : /* @__PURE__ */ g(J, { children: [
191
- /* @__PURE__ */ i(te, { className: "size-4 animate-spin", "aria-hidden": !0 }),
192
- "Opening ",
193
- _,
194
- "…"
195
- ] }) }) }),
196
- /* @__PURE__ */ i(
197
- "textarea",
198
- {
199
- ref: M,
200
- "aria-hidden": !0,
201
- tabIndex: -1,
202
- className: "pointer-events-none absolute left-0 top-0 size-px opacity-0",
203
- style: { fontSize: 16 },
204
- autoCapitalize: "off",
205
- autoCorrect: "off",
206
- spellCheck: !1,
207
- onInput: (e) => {
208
- const t = e.currentTarget, s = t.value;
209
- if (s.length < b.length)
210
- for (let a = s.length; a < b.length; a++) z(j.Backspace);
211
- else
212
- for (const a of s.slice(b.length)) z(ae(a));
213
- t.value = b;
214
- },
215
- onKeyDown: (e) => {
216
- if (e.key === "Enter" || e.key === "Backspace") return;
217
- const t = j[e.key];
218
- t && (e.preventDefault(), z(t));
219
- }
220
- }
221
- )
222
- ] }),
223
- /* @__PURE__ */ i("div", { className: "flex shrink-0 justify-center border-t px-3 py-1.5", children: /* @__PURE__ */ i("button", { type: "button", className: "text-xs text-muted-foreground underline-offset-2 hover:underline", onClick: l, "data-testid": "expo-signin-sheet-full-computer", children: "Open the full Computer view" }) })
224
- ]
225
- }
226
- ) }),
227
- document.body
228
- );
229
- }
230
- export {
231
- F as EXPO_SHEET_TITLE,
232
- ve as ExpoSigninSheet,
233
- ve as default
234
- };