@floegence/floe-webapp-core 0.101.16 → 0.101.19
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/MarkdownMedia.d.ts +1 -0
- package/dist/components/chat/blocks/MarkdownMedia.js +1 -0
- package/dist/components/html-preview/SandboxedHtmlFrame.d.ts +2 -1
- package/dist/components/html-preview/SandboxedHtmlFrame.js +97 -62
- package/dist/components/workbench/WorkbenchFilterBar.d.ts +2 -0
- package/dist/components/workbench/WorkbenchFilterBar.js +282 -279
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -58,6 +58,7 @@ const Fe = (e) => {
|
|
|
58
58
|
const a = e.onOpenLink, i = B();
|
|
59
59
|
return a ? (r, t) => a(i, r, t) : void 0;
|
|
60
60
|
}, G = () => ({
|
|
61
|
+
pointerLocked: e.labels.pointerLocked,
|
|
61
62
|
linkUnavailable: e.labels.linkUnavailable ?? "Opening links is unavailable in this preview.",
|
|
62
63
|
anchorUnavailable: e.labels.anchorUnavailable ?? "The linked section was not found."
|
|
63
64
|
});
|
|
@@ -2,6 +2,7 @@ import { type JSX } from 'solid-js';
|
|
|
2
2
|
export interface SandboxedHtmlFrameLabels {
|
|
3
3
|
linkUnavailable: string;
|
|
4
4
|
anchorUnavailable: string;
|
|
5
|
+
pointerLocked?: string;
|
|
5
6
|
}
|
|
6
7
|
export interface SandboxedHtmlSearch {
|
|
7
8
|
search: (query: string, direction?: -1 | 0 | 1) => void;
|
|
@@ -19,7 +20,7 @@ export interface SandboxedHtmlFrameProps {
|
|
|
19
20
|
class?: string;
|
|
20
21
|
style?: JSX.CSSProperties;
|
|
21
22
|
inert?: boolean;
|
|
22
|
-
/** Deactivation pauses native media
|
|
23
|
+
/** Deactivation pauses native media and releases pointer lock; neither resumes automatically. */
|
|
23
24
|
active?: boolean;
|
|
24
25
|
/** Localized presentation while this exact document loads and reaches a render opportunity. */
|
|
25
26
|
renderPending?: () => JSX.Element;
|
|
@@ -1,18 +1,38 @@
|
|
|
1
|
-
import { insert as
|
|
2
|
-
import { createSignal as
|
|
1
|
+
import { insert as h, createComponent as x, effect as D, setAttribute as v, className as N, style as Q, template as p, use as U } from "solid-js/web";
|
|
2
|
+
import { createSignal as g, createMemo as $, createEffect as T, untrack as j, onCleanup as I, onMount as B, Show as S } from "solid-js";
|
|
3
3
|
import { sandboxedMarkdownHtml as K } from "../chat/markdown/media.js";
|
|
4
|
-
import { findTextRanges as
|
|
5
|
-
import { secureRandomUUID as
|
|
6
|
-
var
|
|
7
|
-
function
|
|
4
|
+
import { findTextRanges as _ } from "../ui/textSearch.js";
|
|
5
|
+
import { secureRandomUUID as z } from "../../utils/secureRandom.js";
|
|
6
|
+
var W = /* @__PURE__ */ p('<span data-floe-html-pending style="position:absolute;inset:0;z-index:1;background:var(--background, Canvas)">'), J = /* @__PURE__ */ p('<span role=status class="pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center px-3"><span class="rounded-md bg-background/95 px-3 py-2 text-xs text-foreground shadow-sm">'), V = /* @__PURE__ */ p('<span role=alert class="max-h-24 shrink-0 overflow-auto break-words bg-background px-3 py-2 text-xs text-destructive">'), X = /* @__PURE__ */ p('<span class="relative flex h-full min-h-0 w-full flex-col"><iframe sandbox="allow-scripts allow-pointer-lock"referrerpolicy=no-referrer style="display:block;width:100%;min-height:0;flex:1 1 0%;border:0">');
|
|
7
|
+
function Y(e) {
|
|
8
8
|
return `<script>(()=>{
|
|
9
9
|
const channel=new MessageChannel();
|
|
10
10
|
const publish=channel.port1.postMessage.bind(channel.port1);
|
|
11
11
|
const query=document.querySelectorAll.bind(document);
|
|
12
12
|
const MediaElementType=HTMLMediaElement;
|
|
13
13
|
const pause=Function.call.bind(MediaElementType.prototype.pause);
|
|
14
|
+
const lockGetter=Object.getOwnPropertyDescriptor(Document.prototype,'pointerLockElement')?.get;
|
|
15
|
+
const locked=lockGetter?Function.call.bind(lockGetter,document):()=>null;
|
|
16
|
+
const exitLock=document.exitPointerLock?.bind(document);
|
|
17
|
+
const hasFocus=document.hasFocus.bind(document);
|
|
18
|
+
let pointerLockAllowed=false,pointerGesture=false;
|
|
19
|
+
const releaseLock=()=>{pointerGesture=false;if(locked())exitLock()};
|
|
20
|
+
window.addEventListener('blur',releaseLock);
|
|
21
|
+
document.addEventListener('visibilitychange',()=>{if(document.hidden)releaseLock()});
|
|
22
|
+
const gesture=event=>{if(event.isTrusted&&pointerLockAllowed)pointerGesture=true};
|
|
23
|
+
window.addEventListener('pointerdown',gesture,true);
|
|
24
|
+
window.addEventListener('keydown',event=>{
|
|
25
|
+
if(event.isTrusted&&event.key==='Escape'&&locked()){event.preventDefault();event.stopImmediatePropagation();releaseLock();return}
|
|
26
|
+
if(event.key==='Enter'||event.key===' ')gesture(event);
|
|
27
|
+
},true);
|
|
28
|
+
document.addEventListener('pointerlockchange',()=>{
|
|
29
|
+
const value=!!locked();
|
|
30
|
+
if(value&&(!pointerLockAllowed||!pointerGesture||!hasFocus()||document.hidden)){releaseLock();return}
|
|
31
|
+
pointerGesture=false;
|
|
32
|
+
publish({type:'pointer-lock',locked:value});
|
|
33
|
+
});
|
|
14
34
|
let active=true,searchEnabled=false,searchOpen=false,searchQuery='',matches=[],matchIndex=0;
|
|
15
|
-
const findRanges=(${
|
|
35
|
+
const findRanges=(${_.toString()});
|
|
16
36
|
const clearHighlights=()=>{CSS.highlights?.delete('floe-html-find');CSS.highlights?.delete('floe-html-find-current')};
|
|
17
37
|
const paint=()=>{
|
|
18
38
|
clearHighlights();
|
|
@@ -38,6 +58,8 @@ function V(e) {
|
|
|
38
58
|
if(event.data?.type==='clear-search'){searchOpen=false;clearHighlights();return}
|
|
39
59
|
if(event.data?.type!=='activation')return;
|
|
40
60
|
active=event.data.active===true;searchEnabled=event.data.searchEnabled===true;
|
|
61
|
+
pointerLockAllowed=event.data.pointerLockAllowed===true;
|
|
62
|
+
if(!pointerLockAllowed)releaseLock();
|
|
41
63
|
paint();
|
|
42
64
|
if(!active)for(const media of query('video,audio'))pause(media);
|
|
43
65
|
};
|
|
@@ -86,52 +108,57 @@ function V(e) {
|
|
|
86
108
|
parent.postMessage({type:'floe-html-ready',token:${JSON.stringify(e)}},'*',[channel.port2]);
|
|
87
109
|
})()<\/script><style>::highlight(floe-html-find){background:#fde68a;color:#111}::highlight(floe-html-find-current){background:#2563eb;color:#fff}</style>`;
|
|
88
110
|
}
|
|
89
|
-
function
|
|
90
|
-
let y,
|
|
91
|
-
const [
|
|
92
|
-
const
|
|
111
|
+
function ae(e) {
|
|
112
|
+
let y, b;
|
|
113
|
+
const [C, f] = g(""), [A, k] = g(!1), [O, R] = g(""), [P, M] = g(), w = $(() => {
|
|
114
|
+
const a = z();
|
|
93
115
|
return {
|
|
94
|
-
token:
|
|
95
|
-
html: K(
|
|
116
|
+
token: a,
|
|
117
|
+
html: K(Y(a) + e.html)
|
|
96
118
|
};
|
|
97
|
-
}), o = () =>
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
}),
|
|
102
|
-
|
|
119
|
+
}), o = () => O() === w().token;
|
|
120
|
+
T(() => {
|
|
121
|
+
const a = o() ? "ready" : "loading";
|
|
122
|
+
j(() => e.onPresentationStateChange?.(a));
|
|
123
|
+
}), T(() => {
|
|
124
|
+
P()?.postMessage({
|
|
103
125
|
type: "activation",
|
|
104
126
|
active: e.active !== !1,
|
|
127
|
+
pointerLockAllowed: e.active !== !1 && !e.inert && o(),
|
|
105
128
|
searchEnabled: !!e.onSearchRequest
|
|
106
129
|
});
|
|
107
|
-
}),
|
|
130
|
+
}), T(() => {
|
|
108
131
|
const {
|
|
109
|
-
token:
|
|
110
|
-
} =
|
|
111
|
-
let i, t = 0, c = 0,
|
|
112
|
-
|
|
113
|
-
!s.isTrusted || s.source !== y.contentWindow || i || s.data?.type !== "floe-html-ready" || s.data?.token !==
|
|
114
|
-
search: (
|
|
115
|
-
|
|
132
|
+
token: a
|
|
133
|
+
} = w(), r = new AbortController();
|
|
134
|
+
let i, t = 0, c = 0, m = !1, l = 0, d;
|
|
135
|
+
f(""), k(!1), b = (s) => {
|
|
136
|
+
!s.isTrusted || s.source !== y.contentWindow || i || s.data?.type !== "floe-html-ready" || s.data?.token !== a || s.ports.length !== 1 || (i = s.ports[0], M(i), e.onSearchReady?.({
|
|
137
|
+
search: (u, n = 0) => {
|
|
138
|
+
r.signal.aborted || e.inert || e.active === !1 || !o() || i?.postMessage({
|
|
116
139
|
type: "search",
|
|
117
|
-
query:
|
|
140
|
+
query: u,
|
|
118
141
|
direction: n,
|
|
119
142
|
request: ++l
|
|
120
143
|
});
|
|
121
144
|
},
|
|
122
145
|
clear: () => {
|
|
123
|
-
|
|
146
|
+
r.signal.aborted || (l++, i?.postMessage({
|
|
124
147
|
type: "clear-search"
|
|
125
148
|
}));
|
|
126
149
|
}
|
|
127
|
-
}), i.onmessage = (
|
|
128
|
-
if (
|
|
129
|
-
const n =
|
|
150
|
+
}), i.onmessage = (u) => {
|
|
151
|
+
if (r.signal.aborted) return;
|
|
152
|
+
const n = u.data;
|
|
153
|
+
if (n?.type === "pointer-lock" && typeof n.locked == "boolean") {
|
|
154
|
+
clearTimeout(d), n.locked && (d = setTimeout(() => k(!1), 3e3)), k(n.locked && !e.inert && e.active !== !1 && o());
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
130
157
|
if (n?.type === "document-loaded") {
|
|
131
|
-
if (
|
|
132
|
-
|
|
158
|
+
if (m) return;
|
|
159
|
+
m = !0, c = requestAnimationFrame(() => {
|
|
133
160
|
c = requestAnimationFrame(() => {
|
|
134
|
-
|
|
161
|
+
r.signal.aborted || R(a);
|
|
135
162
|
});
|
|
136
163
|
});
|
|
137
164
|
return;
|
|
@@ -149,57 +176,65 @@ function ee(e) {
|
|
|
149
176
|
return;
|
|
150
177
|
}
|
|
151
178
|
if (n?.type === "anchor-opened") {
|
|
152
|
-
|
|
179
|
+
f("");
|
|
153
180
|
return;
|
|
154
181
|
}
|
|
155
182
|
if (n?.type === "anchor-missing") {
|
|
156
|
-
|
|
183
|
+
f(e.labels?.anchorUnavailable ?? "The linked section was not found.");
|
|
157
184
|
return;
|
|
158
185
|
}
|
|
159
186
|
if (n?.type !== "open-link" || typeof n.href != "string" || n.href.length > 8192) return;
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
if (!
|
|
163
|
-
if (!
|
|
164
|
-
return
|
|
187
|
+
const E = n.href, F = e.onOpenLink, H = e.labels?.linkUnavailable, G = ++t;
|
|
188
|
+
f(""), Promise.resolve().then(() => {
|
|
189
|
+
if (!r.signal.aborted) {
|
|
190
|
+
if (!F) throw new Error(H ?? "Opening links is unavailable in this preview.");
|
|
191
|
+
return F(E, r.signal);
|
|
165
192
|
}
|
|
166
|
-
}).catch((
|
|
167
|
-
!
|
|
193
|
+
}).catch((L) => {
|
|
194
|
+
!r.signal.aborted && G === t && f(L instanceof Error && L.message ? L.message : H ?? "This link could not be opened.");
|
|
168
195
|
});
|
|
169
196
|
}, i.start());
|
|
170
197
|
}, I(() => {
|
|
171
|
-
|
|
198
|
+
clearTimeout(d), r.abort(), cancelAnimationFrame(c), i?.close(), M(void 0), b = void 0, e.onSearchReady?.(void 0);
|
|
172
199
|
});
|
|
173
200
|
});
|
|
174
|
-
const
|
|
175
|
-
return
|
|
176
|
-
window.addEventListener("message",
|
|
201
|
+
const q = (a) => b?.(a);
|
|
202
|
+
return B(() => {
|
|
203
|
+
window.addEventListener("message", q), I(() => window.removeEventListener("message", q));
|
|
177
204
|
}), (() => {
|
|
178
|
-
var
|
|
179
|
-
|
|
205
|
+
var a = X(), r = a.firstChild;
|
|
206
|
+
h(a, x(S, {
|
|
180
207
|
get when() {
|
|
181
208
|
return !o();
|
|
182
209
|
},
|
|
183
210
|
get children() {
|
|
184
|
-
var t =
|
|
185
|
-
return
|
|
211
|
+
var t = W();
|
|
212
|
+
return h(t, () => e.renderPending?.()), t;
|
|
186
213
|
}
|
|
187
|
-
}),
|
|
214
|
+
}), r);
|
|
188
215
|
var i = y;
|
|
189
|
-
return typeof i == "function" ?
|
|
216
|
+
return typeof i == "function" ? U(i, r) : y = r, h(a, x(S, {
|
|
217
|
+
get when() {
|
|
218
|
+
return A();
|
|
219
|
+
},
|
|
220
|
+
get children() {
|
|
221
|
+
var t = J(), c = t.firstChild;
|
|
222
|
+
return h(c, () => e.labels?.pointerLocked ?? "Mouse locked; press Esc to exit"), t;
|
|
223
|
+
}
|
|
224
|
+
}), null), h(a, x(S, {
|
|
190
225
|
get when() {
|
|
191
|
-
return
|
|
226
|
+
return C();
|
|
192
227
|
},
|
|
193
228
|
get children() {
|
|
194
|
-
var t =
|
|
195
|
-
return
|
|
229
|
+
var t = V();
|
|
230
|
+
return h(t, C), t;
|
|
196
231
|
}
|
|
197
|
-
}), null),
|
|
198
|
-
var c = o() ? "ready" : "loading",
|
|
232
|
+
}), null), D((t) => {
|
|
233
|
+
var c = o() ? "ready" : "loading", m = !o(), l = e.class, d = e.title, s = w().html, u = e.inert || e.active === !1 || !o(), n = e.inert || e.active === !1 || !o() ? -1 : e.tabIndex, E = {
|
|
199
234
|
...e.style,
|
|
200
235
|
opacity: o() ? void 0 : "0"
|
|
201
236
|
};
|
|
202
|
-
return c !== t.e &&
|
|
237
|
+
return c !== t.e && v(a, "data-floe-html-state", t.e = c), m !== t.t && v(a, "aria-busy", t.t = m), l !== t.a && N(r, t.a = l), d !== t.o && v(r, "title", t.o = d), s !== t.i && v(r, "srcdoc", t.i = s), u !== t.n && (r.inert = t.n = u), n !== t.s && v(r, "tabindex", t.s = n), t.h = Q(r, E, t.h), t;
|
|
203
238
|
}, {
|
|
204
239
|
e: void 0,
|
|
205
240
|
t: void 0,
|
|
@@ -209,9 +244,9 @@ function ee(e) {
|
|
|
209
244
|
n: void 0,
|
|
210
245
|
s: void 0,
|
|
211
246
|
h: void 0
|
|
212
|
-
}),
|
|
247
|
+
}), a;
|
|
213
248
|
})();
|
|
214
249
|
}
|
|
215
250
|
export {
|
|
216
|
-
|
|
251
|
+
ae as SandboxedHtmlFrame
|
|
217
252
|
};
|
|
@@ -61,6 +61,8 @@ export type WorkbenchDockAction = Readonly<{
|
|
|
61
61
|
/** Places the action before or after components, always before host items in that group. */
|
|
62
62
|
dockPlacement?: WorkbenchDockItemPlacement;
|
|
63
63
|
onActivate: (trigger: HTMLButtonElement) => void;
|
|
64
|
+
/** Receives the concrete action button on mount and null on disposal. */
|
|
65
|
+
buttonRef?: (button: HTMLButtonElement | null) => void;
|
|
64
66
|
}>;
|
|
65
67
|
export type WorkbenchHostDockItem = Readonly<{
|
|
66
68
|
id: string;
|