@simon_he/vue-tui 1.1.6 → 1.1.9

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.
Files changed (40) hide show
  1. package/README.md +1 -0
  2. package/dist/TAgentTerminalGraphic-B8-YZfuP.js +1198 -0
  3. package/dist/{TSelect-CMBOOFwK.js → TSelect-CCsjjCOr.js} +41 -12
  4. package/dist/{TTree-kk8ntrpg.js → TTree-3W5A2_EH.js} +4 -3
  5. package/dist/TVideo-D9AOiyq2.js +948 -0
  6. package/dist/agent.cjs +4926 -4364
  7. package/dist/agent.js +11 -9
  8. package/dist/{block-source-DByORvKG.js → block-source-BhvdZomx.js} +3 -3
  9. package/dist/cli.cjs +1 -1
  10. package/dist/cli.js +8 -1
  11. package/dist/core.js +2 -2
  12. package/dist/experimental/browser.cjs +3705 -0
  13. package/dist/experimental/browser.d.cts +3 -0
  14. package/dist/experimental/browser.d.ts +3 -0
  15. package/dist/experimental/browser.js +413 -0
  16. package/dist/experimental.cjs +1 -1
  17. package/dist/experimental.js +9 -947
  18. package/dist/{linkify-CL9wwnZN.js → frame-mailbox-DaTrfyaF.js} +2 -297
  19. package/dist/index.cjs +25 -8
  20. package/dist/index.js +6 -5
  21. package/dist/linkify-CklfA1vp.js +298 -0
  22. package/dist/markdown.cjs +4907 -4362
  23. package/dist/markdown.js +4 -4
  24. package/dist/{mermaid-CWy4wtCL.js → mermaid-D0ov4_A1.js} +3 -3
  25. package/dist/mermaid.cjs +1 -1
  26. package/dist/mermaid.js +4 -4
  27. package/dist/{path-suggest-Dndu4dTi.js → path-suggest-fPzRsgPv.js} +1 -1
  28. package/dist/renderer/terminal-graphics.d.ts +1 -1
  29. package/dist/{terminal-graphics-D6KErRBY.js → terminal-graphics-DpSL29OQ.js} +1 -1
  30. package/dist/{tlog-theme-DIrlCw6m.js → tlog-theme-BnILsD3n.js} +10 -1203
  31. package/dist/vue/browser/types.d.ts +52 -0
  32. package/dist/vue/components/TBrowser.d.ts +231 -0
  33. package/dist/vue/components/input/plugins/promptMentionPlugin.d.ts +3 -0
  34. package/dist/vue.cjs +25 -8
  35. package/dist/vue.js +8 -7
  36. package/package.json +16 -2
  37. /package/dist/{TMermaidText-wLnMMvVS.js → TMermaidText-C1akgJPU.js} +0 -0
  38. /package/dist/{math-image-BZhmfUeu.js → math-image-CcUpBnW0.js} +0 -0
  39. /package/dist/{path-mnSgEpCm.js → path-BI9W15Zt.js} +0 -0
  40. /package/dist/{wheel-scroll-DASkEZr-.js → wheel-scroll-CQ22Hcyj.js} +0 -0
@@ -0,0 +1,3 @@
1
+ export { TBrowser } from "../vue/components/TBrowser.js";
2
+ export type { TBrowserProps } from "../vue/components/TBrowser.js";
3
+ export type { TBrowserInputEvent, TBrowserModifiers, TBrowserSession, TBrowserSessionContext, TBrowserSessionFactory, } from "../vue/browser/types.js";
@@ -0,0 +1,3 @@
1
+ export { TBrowser } from "../vue/components/TBrowser.js";
2
+ export type { TBrowserProps } from "../vue/components/TBrowser.js";
3
+ export type { TBrowserInputEvent, TBrowserModifiers, TBrowserSession, TBrowserSessionContext, TBrowserSessionFactory, } from "../vue/browser/types.js";
@@ -0,0 +1,413 @@
1
+ import "../create-terminal-Db_-UGVQ.js";
2
+ import { intersectRect, translateRect, useLayout, useTerminal, useTerminalNode, useVisibility } from "../rect-JzWMJxxc.js";
3
+ import "../frame-mailbox-DaTrfyaF.js";
4
+ import "../terminal-graphics-DpSL29OQ.js";
5
+ import "../TAgentTerminalGraphic-B8-YZfuP.js";
6
+ import { TVideo } from "../TVideo-D9AOiyq2.js";
7
+ import { computed, defineComponent, h, onBeforeUnmount, watch, watchEffect } from "vue";
8
+
9
+ //#region src/vue/components/TBrowser.ts
10
+ const EMPTY_RECT = Object.freeze({
11
+ x: 0,
12
+ y: 0,
13
+ w: 0,
14
+ h: 0
15
+ });
16
+ const tBrowserProps = {
17
+ x: {
18
+ type: Number,
19
+ required: true
20
+ },
21
+ y: {
22
+ type: Number,
23
+ required: true
24
+ },
25
+ w: {
26
+ type: Number,
27
+ required: true
28
+ },
29
+ h: {
30
+ type: Number,
31
+ required: true
32
+ },
33
+ zIndex: {
34
+ type: Number,
35
+ default: 0
36
+ },
37
+ url: {
38
+ type: String,
39
+ required: true
40
+ },
41
+ sessionFactory: {
42
+ type: Function,
43
+ required: true
44
+ },
45
+ autoFocus: {
46
+ type: Boolean,
47
+ default: false
48
+ },
49
+ maxFps: {
50
+ type: Number,
51
+ default: 60
52
+ },
53
+ pixelWidth: {
54
+ type: Number,
55
+ default: void 0
56
+ },
57
+ pixelHeight: {
58
+ type: Number,
59
+ default: void 0
60
+ },
61
+ fallback: {
62
+ type: String,
63
+ default: "[browser requires terminal graphics]"
64
+ },
65
+ style: {
66
+ type: Object,
67
+ default: void 0
68
+ },
69
+ clear: {
70
+ type: Boolean,
71
+ default: true
72
+ }
73
+ };
74
+ function modifiers(event) {
75
+ return {
76
+ ctrl: Boolean(event.ctrlKey),
77
+ shift: Boolean(event.shiftKey),
78
+ alt: Boolean(event.altKey),
79
+ meta: Boolean(event.metaKey)
80
+ };
81
+ }
82
+ function eventText(event) {
83
+ return String(event.text ?? event.data ?? "");
84
+ }
85
+ function isBrowserShortcut(event) {
86
+ const key = event.key.toLowerCase();
87
+ return (event.ctrlKey || event.metaKey) && [
88
+ "l",
89
+ "r",
90
+ "t",
91
+ "w"
92
+ ].includes(key) || Boolean(event.altKey) && (event.key === "ArrowLeft" || event.key === "ArrowRight") || Boolean(event.ctrlKey) && (key === "c" || key === "q");
93
+ }
94
+ const TBrowser = defineComponent({
95
+ name: "TBrowser",
96
+ props: tBrowserProps,
97
+ emits: {
98
+ ready: (_session) => true,
99
+ frame: (_event) => true,
100
+ navigate: (_url) => true,
101
+ titleChange: (_title) => true,
102
+ requestAddress: () => true,
103
+ close: () => true,
104
+ error: (_error) => true
105
+ },
106
+ setup(props, { emit }) {
107
+ const layout = useLayout();
108
+ const { events } = useTerminal();
109
+ const { visible } = useVisibility();
110
+ let activeSession = null;
111
+ let activePixelWidth = Math.max(1, Math.floor(props.pixelWidth ?? props.w * 8));
112
+ let activePixelHeight = Math.max(1, Math.floor(props.pixelHeight ?? props.h * 16));
113
+ let alive = true;
114
+ let skipNextInput = false;
115
+ let requestedUrl = props.url;
116
+ let sessionQueue = Promise.resolve();
117
+ let continuousInputScheduled = false;
118
+ let continuousInputGeneration = 0;
119
+ const pendingContinuousInput = [];
120
+ const initialUrl = props.url;
121
+ const initialPixelWidth = Math.max(2, Math.floor(props.pixelWidth ?? props.w * 8));
122
+ const initialPixelHeight = Math.max(2, Math.floor(props.pixelHeight ?? props.h * 16));
123
+ const rawRect = computed(() => translateRect({
124
+ x: Math.floor(props.x),
125
+ y: Math.floor(props.y),
126
+ w: Math.max(0, Math.floor(props.w)),
127
+ h: Math.max(0, Math.floor(props.h))
128
+ }, layout.originX, layout.originY));
129
+ const rect = computed(() => {
130
+ const value = rawRect.value;
131
+ return layout.clipRect ? intersectRect(value, layout.clipRect) ?? EMPTY_RECT : value;
132
+ });
133
+ const frameSource = async function* (context) {
134
+ activePixelWidth = context.pixelWidth;
135
+ activePixelHeight = context.pixelHeight;
136
+ const session = await props.sessionFactory({
137
+ url: context.src,
138
+ signal: context.signal,
139
+ maxFps: context.maxFps,
140
+ pixelWidth: context.pixelWidth,
141
+ pixelHeight: context.pixelHeight,
142
+ preferredFormat: context.preferredFormat,
143
+ onNavigate: (url) => emit("navigate", url),
144
+ onTitleChange: (title) => emit("titleChange", title)
145
+ });
146
+ if (context.signal.aborted || !alive) {
147
+ await session.close();
148
+ return;
149
+ }
150
+ clearContinuousInput();
151
+ sessionQueue = Promise.resolve();
152
+ activeSession = session;
153
+ try {
154
+ if (requestedUrl !== context.src && session.navigate) await session.navigate(requestedUrl);
155
+ if (context.signal.aborted || !alive) return;
156
+ emit("ready", session);
157
+ for await (const frame of session.frames) {
158
+ if (context.signal.aborted || !alive) return;
159
+ yield frame;
160
+ }
161
+ } finally {
162
+ if (activeSession === session) {
163
+ activeSession = null;
164
+ clearContinuousInput();
165
+ }
166
+ await session.close();
167
+ }
168
+ };
169
+ function reportError(error) {
170
+ if (alive) emit("error", error);
171
+ }
172
+ function clearContinuousInput() {
173
+ pendingContinuousInput.length = 0;
174
+ continuousInputGeneration++;
175
+ continuousInputScheduled = false;
176
+ }
177
+ function scheduleContinuousInput(session) {
178
+ if (continuousInputScheduled || pendingContinuousInput.length === 0) return;
179
+ const event = pendingContinuousInput.shift();
180
+ const generation = continuousInputGeneration;
181
+ continuousInputScheduled = true;
182
+ const pending = sessionQueue.then(() => {
183
+ if (generation !== continuousInputGeneration || activeSession !== session) return;
184
+ return session.dispatch(event);
185
+ });
186
+ sessionQueue = pending.catch((error) => {
187
+ if (activeSession === session) reportError(error);
188
+ });
189
+ const finish = () => {
190
+ if (generation !== continuousInputGeneration) return;
191
+ continuousInputScheduled = false;
192
+ if (activeSession === session) scheduleContinuousInput(session);
193
+ };
194
+ pending.then(finish, finish);
195
+ }
196
+ function queueContinuousInput(session, event) {
197
+ const index = pendingContinuousInput.findIndex((pending) => pending.type === event.type);
198
+ if (index < 0) pendingContinuousInput.push(event);
199
+ else if (event.type === "wheel") {
200
+ const previous = pendingContinuousInput[index];
201
+ const deltaY = (previous?.type === "wheel" ? previous.deltaY : 0) + event.deltaY;
202
+ if (deltaY === 0) pendingContinuousInput.splice(index, 1);
203
+ else pendingContinuousInput[index] = {
204
+ ...event,
205
+ deltaY
206
+ };
207
+ } else pendingContinuousInput[index] = event;
208
+ scheduleContinuousInput(session);
209
+ }
210
+ function dispatch(event) {
211
+ const session = activeSession;
212
+ if (!session) return;
213
+ if (event.type === "wheel" || event.type === "pointermove") {
214
+ queueContinuousInput(session, event);
215
+ return;
216
+ }
217
+ clearContinuousInput();
218
+ const pending = sessionQueue.then(() => {
219
+ if (activeSession !== session) return;
220
+ return session.dispatch(event);
221
+ });
222
+ sessionQueue = pending.catch((error) => {
223
+ if (activeSession === session) reportError(error);
224
+ });
225
+ }
226
+ function invoke(action) {
227
+ const session = activeSession;
228
+ if (!session) return;
229
+ clearContinuousInput();
230
+ const pending = sessionQueue.then(() => {
231
+ if (activeSession !== session) return;
232
+ return action(session);
233
+ });
234
+ sessionQueue = pending.catch((error) => {
235
+ if (activeSession === session) reportError(error);
236
+ });
237
+ }
238
+ function closeCurrentPage() {
239
+ const session = activeSession;
240
+ if (!session?.closePage) {
241
+ emit("close");
242
+ return;
243
+ }
244
+ clearContinuousInput();
245
+ const pending = sessionQueue.then(() => {
246
+ if (activeSession !== session) return;
247
+ return session.closePage?.();
248
+ }).then((closed) => {
249
+ if (closed === false && activeSession === session) emit("close");
250
+ });
251
+ sessionQueue = pending.catch((error) => {
252
+ if (activeSession === session) reportError(error);
253
+ });
254
+ }
255
+ function point(event) {
256
+ const bounds = rawRect.value;
257
+ const cellX = Math.max(0, Math.min(bounds.w - 1, Math.floor(event.cellX - bounds.x)));
258
+ const cellY = Math.max(0, Math.min(bounds.h - 1, Math.floor(event.cellY - bounds.y)));
259
+ return {
260
+ x: Math.max(0, Math.min(activePixelWidth - 1, (cellX + .5) / bounds.w * activePixelWidth)),
261
+ y: Math.max(0, Math.min(activePixelHeight - 1, (cellY + .5) / bounds.h * activePixelHeight))
262
+ };
263
+ }
264
+ function capture(event) {
265
+ event.preventDefault();
266
+ event.stopPropagation();
267
+ }
268
+ function pointer(type, event) {
269
+ if (type === "pointerdown" && id.value) events.value?.focus(id.value);
270
+ capture(event);
271
+ dispatch({
272
+ type,
273
+ ...point(event),
274
+ button: event.button,
275
+ buttons: event.buttons,
276
+ modifiers: modifiers(event)
277
+ });
278
+ }
279
+ const { id } = useTerminalNode(() => ({
280
+ rect: rect.value,
281
+ zIndex: props.zIndex,
282
+ visible: visible.value,
283
+ focusable: true,
284
+ selectable: false,
285
+ handlers: {
286
+ pointerdown: (event) => pointer("pointerdown", event),
287
+ pointerup: (event) => pointer("pointerup", event),
288
+ pointermove: (event) => pointer("pointermove", event),
289
+ wheel: (event) => {
290
+ capture(event);
291
+ dispatch({
292
+ type: "wheel",
293
+ ...point(event),
294
+ deltaY: Number(event.deltaY ?? 0),
295
+ modifiers: modifiers(event)
296
+ });
297
+ },
298
+ keydown: (event) => {
299
+ capture(event);
300
+ if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "l") {
301
+ emit("requestAddress");
302
+ return;
303
+ }
304
+ if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "r") {
305
+ invoke((session) => session.reload?.());
306
+ return;
307
+ }
308
+ if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "t") {
309
+ invoke((session) => session.newPage?.());
310
+ emit("requestAddress");
311
+ return;
312
+ }
313
+ if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "w") {
314
+ closeCurrentPage();
315
+ return;
316
+ }
317
+ if (event.altKey && event.key === "ArrowLeft") {
318
+ invoke((session) => session.back?.());
319
+ return;
320
+ }
321
+ if (event.altKey && event.key === "ArrowRight") {
322
+ invoke((session) => session.forward?.());
323
+ return;
324
+ }
325
+ if (event.ctrlKey && ["c", "q"].includes(event.key.toLowerCase())) {
326
+ emit("close");
327
+ return;
328
+ }
329
+ dispatch({
330
+ type: "keydown",
331
+ key: event.key,
332
+ code: event.code,
333
+ repeat: Boolean(event.repeat),
334
+ modifiers: modifiers(event)
335
+ });
336
+ },
337
+ keyup: (event) => {
338
+ capture(event);
339
+ if (isBrowserShortcut(event)) return;
340
+ dispatch({
341
+ type: "keyup",
342
+ key: event.key,
343
+ code: event.code,
344
+ repeat: Boolean(event.repeat),
345
+ modifiers: modifiers(event)
346
+ });
347
+ },
348
+ paste: (event) => {
349
+ capture(event);
350
+ const text = eventText(event);
351
+ if (text) dispatch({
352
+ type: "paste",
353
+ text
354
+ });
355
+ },
356
+ compositionend: (event) => {
357
+ capture(event);
358
+ const text = eventText(event);
359
+ if (text) dispatch({
360
+ type: "text",
361
+ text
362
+ });
363
+ skipNextInput = true;
364
+ queueMicrotask(() => {
365
+ skipNextInput = false;
366
+ });
367
+ },
368
+ input: (event) => {
369
+ capture(event);
370
+ if (skipNextInput) return;
371
+ const text = eventText(event);
372
+ if (text) dispatch({
373
+ type: "text",
374
+ text
375
+ });
376
+ }
377
+ }
378
+ }));
379
+ watchEffect(() => {
380
+ if (!props.autoFocus || !visible.value || !id.value) return;
381
+ if (events.value?.getFocused() !== id.value) events.value?.focus(id.value);
382
+ });
383
+ watch(() => props.url, (url) => {
384
+ requestedUrl = url;
385
+ if (activeSession?.navigate) invoke((session) => session.navigate?.(url));
386
+ });
387
+ onBeforeUnmount(() => {
388
+ alive = false;
389
+ activeSession = null;
390
+ clearContinuousInput();
391
+ });
392
+ return () => h(TVideo, {
393
+ x: props.x,
394
+ y: props.y,
395
+ w: props.w,
396
+ h: props.h,
397
+ zIndex: props.zIndex,
398
+ src: initialUrl,
399
+ frameSource,
400
+ maxFps: props.maxFps,
401
+ pixelWidth: props.pixelWidth ?? initialPixelWidth,
402
+ pixelHeight: props.pixelHeight ?? initialPixelHeight,
403
+ fallback: props.fallback,
404
+ style: props.style,
405
+ clear: props.clear,
406
+ onFrame: (event) => emit("frame", event),
407
+ onError: (error) => emit("error", error)
408
+ });
409
+ }
410
+ });
411
+
412
+ //#endregion
413
+ export { TBrowser };
@@ -2154,7 +2154,7 @@ function getRootTerminal(terminal) {
2154
2154
  }
2155
2155
 
2156
2156
  // src/renderer/terminal-graphics.ts
2157
- var ESC2 = "\x1B", BEL = "\x07", ST = `${ESC2}\\`, ESC_RE = "\\u001B", BEL_RE = "\\u0007", CSI_RE = new RegExp(`${ESC_RE}\\[[0-?]*[ -/]*[@-~]`, "g"), OSC_RE = new RegExp(`${ESC_RE}\\][\\s\\S]*?(?:${BEL_RE}|${ESC_RE}\\\\)`, "g"), DCS_RE = new RegExp(`${ESC_RE}P[\\s\\S]*?${ESC_RE}\\\\`, "g"), APC_RE = new RegExp(`${ESC_RE}_[\\s\\S]*?${ESC_RE}\\\\`, "g"), C1_CSI_RE = new RegExp("\\u009B[0-?]*[ -/]*[@-~]", "g"), C1_OSC_RE = new RegExp(`\\u009D[\\s\\S]*?(?:${BEL_RE}|\\u009C)`, "g"), C1_DCS_RE = new RegExp("\\u0090[\\s\\S]*?\\u009C", "g"), C1_APC_RE = new RegExp("\\u009F[\\s\\S]*?\\u009C", "g"), MAX_TERMINAL_GRAPHICS_SEQUENCE_CHARS = 16 * 1024 * 1024, MAX_TERMINAL_GRAPHICS_FALLBACK_CHARS = 16384, MAX_TERMINAL_GRAPHIC_CELLS = 1e4, TERMINAL_GRAPHICS_REGISTRY = Symbol.for("@simon_he/vue-tui:v1:terminal-graphics"), terminalGraphicsGlobal = globalThis, terminalGraphicsRegistry = terminalGraphicsGlobal[TERMINAL_GRAPHICS_REGISTRY] ?? {
2157
+ var ESC2 = "\x1B", BEL = "\x07", ST = `${ESC2}\\`, ESC_RE = "\\u001B", BEL_RE = "\\u0007", CSI_RE = new RegExp(`${ESC_RE}\\[[0-?]*[ -/]*[@-~]`, "g"), OSC_RE = new RegExp(`${ESC_RE}\\][\\s\\S]*?(?:${BEL_RE}|${ESC_RE}\\\\)`, "g"), DCS_RE = new RegExp(`${ESC_RE}P[\\s\\S]*?${ESC_RE}\\\\`, "g"), APC_RE = new RegExp(`${ESC_RE}_[\\s\\S]*?${ESC_RE}\\\\`, "g"), C1_CSI_RE = new RegExp("\\u009B[0-?]*[ -/]*[@-~]", "g"), C1_OSC_RE = new RegExp(`\\u009D[\\s\\S]*?(?:${BEL_RE}|\\u009C)`, "g"), C1_DCS_RE = new RegExp("\\u0090[\\s\\S]*?\\u009C", "g"), C1_APC_RE = new RegExp("\\u009F[\\s\\S]*?\\u009C", "g"), MAX_TERMINAL_GRAPHICS_SEQUENCE_CHARS = 16 * 1024 * 1024, MAX_TERMINAL_GRAPHICS_FALLBACK_CHARS = 16384, MAX_TERMINAL_GRAPHIC_CELLS = 1e5, TERMINAL_GRAPHICS_REGISTRY = Symbol.for("@simon_he/vue-tui:v1:terminal-graphics"), terminalGraphicsGlobal = globalThis, terminalGraphicsRegistry = terminalGraphicsGlobal[TERMINAL_GRAPHICS_REGISTRY] ?? {
2158
2158
  outputs: /* @__PURE__ */ new WeakMap(),
2159
2159
  outputVersions: /* @__PURE__ */ new WeakMap(),
2160
2160
  outputListeners: /* @__PURE__ */ new WeakMap()