agent-yes 1.236.0 → 1.237.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/dist/{JsonlStore-CWOA3aDH.js → JsonlStore-CPGIR0Wy.js} +1 -1
- package/dist/SUPPORTED_CLIS-C0RwjYrz.js +11 -0
- package/dist/{SUPPORTED_CLIS-C7bkkXue.js → SUPPORTED_CLIS-CDrJz9Xo.js} +2 -2
- package/dist/{agent-yes.config-BhjzWavn.js → agent-yes.config-DPtMM0S-.js} +2 -2
- package/dist/{agentShare-BxAaZ-UR.js → agentShare-Cl_J3dfx.js} +9 -9
- package/dist/{agentYesHome-CtHb5b71.js → agentYesHome-CtmsY6I-.js} +1 -1
- package/dist/browser-B3dOptjL.js +311 -0
- package/dist/browser-BRMyG4JA.js +13514 -0
- package/dist/callback-CFbkvqTh.js +12 -0
- package/dist/{callback-B1AWp2tC.js → callback-D0_AeyN1.js} +6 -6
- package/dist/{callbackCore-CcbVa8r2.js → callbackCore-CvmGSvrj.js} +1 -1
- package/dist/{callbackCore-Me97qn68.js → callbackCore-DAYcemCC.js} +1 -1
- package/dist/{channels-Lsot9pyU.js → channels-BiGUYTuz.js} +2 -2
- package/dist/{channels-DHXLnU4r.js → channels-CMNMFJlY.js} +6 -6
- package/dist/channels.js +6 -310
- package/dist/chunk-cZBX9HZv.js +20 -0
- package/dist/cli.js +11 -11
- package/dist/{configShared-BXz2vi4Q.js → configShared-9wVlbPyC.js} +1 -1
- package/dist/{cwdConflictWarn-ArYYtOGy.js → cwdConflictWarn-DWHWlBxS.js} +2 -2
- package/dist/{cwdDeprecation-BGX20-Fe.js → cwdDeprecation-Cd8Ykm2t.js} +1 -1
- package/dist/{e2e-CYlKpfxa.js → e2e-CEIdJGZ7.js} +1 -1
- package/dist/{expose-ByT4ef7C.js → expose-DROTwbyU.js} +1 -1
- package/dist/{forkNested-Bai0Q7BL.js → forkNested-DqPisz9d.js} +2 -2
- package/dist/{globalPidIndex-Ca4sTr1b.js → globalPidIndex-D9DOSd-c.js} +1 -1
- package/dist/index.js +7 -7
- package/dist/{messageLog-zVGWLX7w.js → messageLog-C-YIzhRj.js} +1 -1
- package/dist/{nodeRuntime-fVRbz6w6.js → nodeRuntime-Bf88NPqj.js} +2 -2
- package/dist/{notifyDaemon-Cxb0-5a0.js → notifyDaemon-D_8TRVHt.js} +8 -8
- package/dist/{openBrowser-DL-EO8Hi.js → openBrowser-ChLcPELv.js} +1 -1
- package/dist/{peer-68ZwnxLs.js → peer-B5JKF4BP.js} +3 -3
- package/dist/peer-D5lr1Afv.js +4 -0
- package/dist/{pidStore-Hjba3K6Q.js → pidStore-6EZd5DUv.js} +4 -4
- package/dist/pidStore-bCVS2Ldt.js +6 -0
- package/dist/{reaper-iQXyufgp.js → reaper-DP49VCKx.js} +2 -2
- package/dist/{reaper-pJpMYKmj.js → reaper-IhkB_RO0.js} +1 -1
- package/dist/{remotes-CF1LJLxY.js → remotes-BClMgQZW.js} +3 -3
- package/dist/{remotes-BDdfhL6N.js → remotes-Bem6WIyU.js} +3 -3
- package/dist/{runningLock-BFk3Mo8K.js → runningLock-DBoONoM-.js} +1 -1
- package/dist/{rustBinary-CFSG7it2.js → rustBinary-Bb9qJZ5w.js} +2 -2
- package/dist/{schedule-CXHdiUHa.js → schedule-B8Erb3y6.js} +11 -11
- package/dist/{serve-DEEwIlVV.js → serve-QejbNTr-.js} +187 -43
- package/dist/{setup-QfDtv5tw.js → setup-Dzi5Cc3g.js} +3 -3
- package/dist/{share-CDER9qNq.js → share--aHaPSjt.js} +2 -2
- package/dist/{share-D4K0JnHg.js → share-B9u8-I3y.js} +2 -2
- package/dist/{spawnGate-PwzImpOw.js → spawnGate-Bo_LFgt9.js} +3 -3
- package/dist/spawnGate-CuWCd2im.js +5 -0
- package/dist/{store-BXJERNbW.js → store-Ck0XRn-K.js} +1 -1
- package/dist/{subcommands-_Ci82sb1.js → subcommands-DFr-5FOL.js} +26 -21
- package/dist/{subcommands-m2DRpvHt.js → subcommands-ymJWO2iv.js} +7 -7
- package/dist/terminal-vNeFNLT8.js +138 -0
- package/dist/terminal.js +3 -0
- package/dist/{todoAutomation-x6guaQXc.js → todoAutomation-Buo457VO.js} +2 -2
- package/dist/{todoCli-CAMVVz9u.js → todoCli-CNNR9Czu.js} +4 -4
- package/dist/{tray-CF8xRQqt.js → tray-D5qFaqlS.js} +2 -2
- package/dist/{ts-D1FDmhc-.js → ts-Dd1FK7sR.js} +11 -28
- package/dist/{versionChecker-DJEtU1JU.js → versionChecker-XfEBINhH.js} +2 -2
- package/dist/{webrtcLink-CEYNs0pt.js → webrtcLink-VQhWmKOw.js} +2 -2
- package/dist/{webrtcRemote-CNC_bMH6.js → webrtcRemote-DJDtCTpj.js} +3 -3
- package/dist/widgets.js +7 -0
- package/dist/{workspaceConfig-CuGjX2_R.js → workspaceConfig-B7HaQ-MI.js} +2 -2
- package/dist/{ws-C7B4xWQl.js → ws-Dun8gGiV.js} +9 -9
- package/package.json +13 -1
- package/ts/serve.ts +144 -5
- package/ts/subcommands.ts +6 -0
- package/ts/termToken.spec.ts +44 -0
- package/ts/termToken.ts +85 -0
- package/ts/terminal/browser.ts +607 -0
- package/ts/terminal.spec.ts +50 -0
- package/ts/terminal.ts +245 -0
- package/ts/widgets.ts +14 -0
- package/dist/SUPPORTED_CLIS-BDXbzEWF.js +0 -11
- package/dist/callback-Dtk0wMsl.js +0 -12
- package/dist/peer-CX4qQx5U.js +0 -4
- package/dist/pidStore-Cp3HekUh.js +0 -6
- package/dist/spawnGate-C21TL4f2.js +0 -5
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "./logger-CDIsZ-Pp.js";
|
|
2
|
+
import "./versionChecker-XfEBINhH.js";
|
|
3
|
+
import "./ts-Dd1FK7sR.js";
|
|
4
|
+
import "./todoAutomation-Buo457VO.js";
|
|
5
|
+
import "./JsonlStore-CPGIR0Wy.js";
|
|
6
|
+
import "./globalPidIndex-D9DOSd-c.js";
|
|
7
|
+
import "./pidStore-6EZd5DUv.js";
|
|
8
|
+
import "./messageLog-C-YIzhRj.js";
|
|
9
|
+
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-CDrJz9Xo.js";
|
|
10
|
+
|
|
11
|
+
export { SUPPORTED_CLIS };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as CLIS_CONFIG } from "./ts-
|
|
1
|
+
import { t as CLIS_CONFIG } from "./ts-Dd1FK7sR.js";
|
|
2
2
|
|
|
3
3
|
//#region ts/SUPPORTED_CLIS.ts
|
|
4
4
|
const SUPPORTED_CLIS = Object.keys(CLIS_CONFIG);
|
|
5
5
|
|
|
6
6
|
//#endregion
|
|
7
7
|
export { SUPPORTED_CLIS as t };
|
|
8
|
-
//# sourceMappingURL=SUPPORTED_CLIS-
|
|
8
|
+
//# sourceMappingURL=SUPPORTED_CLIS-CDrJz9Xo.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as logger } from "./logger-CDIsZ-Pp.js";
|
|
2
|
-
import { n as normalizeAgentYesConfig, t as loadSharedCliDefaults } from "./configShared-
|
|
2
|
+
import { n as normalizeAgentYesConfig, t as loadSharedCliDefaults } from "./configShared-9wVlbPyC.js";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
@@ -226,4 +226,4 @@ async function getDefaultConfig() {
|
|
|
226
226
|
|
|
227
227
|
//#endregion
|
|
228
228
|
export { agent_yes_config_default as default };
|
|
229
|
-
//# sourceMappingURL=agent-yes.config-
|
|
229
|
+
//# sourceMappingURL=agent-yes.config-DPtMM0S-.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "./logger-CDIsZ-Pp.js";
|
|
2
|
-
import "./globalPidIndex-
|
|
3
|
-
import "./messageLog-
|
|
4
|
-
import "./e2e-
|
|
5
|
-
import "./configShared-
|
|
6
|
-
import { N as resolveOne } from "./subcommands-
|
|
7
|
-
import "./webrtcLink-
|
|
8
|
-
import "./remotes-
|
|
9
|
-
import { a as startShare } from "./share-
|
|
2
|
+
import "./globalPidIndex-D9DOSd-c.js";
|
|
3
|
+
import "./messageLog-C-YIzhRj.js";
|
|
4
|
+
import "./e2e-CEIdJGZ7.js";
|
|
5
|
+
import "./configShared-9wVlbPyC.js";
|
|
6
|
+
import { N as resolveOne } from "./subcommands-DFr-5FOL.js";
|
|
7
|
+
import "./webrtcLink-VQhWmKOw.js";
|
|
8
|
+
import "./remotes-Bem6WIyU.js";
|
|
9
|
+
import { a as startShare } from "./share-B9u8-I3y.js";
|
|
10
10
|
|
|
11
11
|
//#region ts/agentShare.ts
|
|
12
12
|
const MAX_SHARES = 8;
|
|
@@ -229,4 +229,4 @@ function transformEvent(rawEvent, agentId, forwarded) {
|
|
|
229
229
|
|
|
230
230
|
//#endregion
|
|
231
231
|
export { createScopedShare, listShares, revokeAllShares, revokeShare };
|
|
232
|
-
//# sourceMappingURL=agentShare-
|
|
232
|
+
//# sourceMappingURL=agentShare-Cl_J3dfx.js.map
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { d as randomHex } from "./e2e-CEIdJGZ7.js";
|
|
2
|
+
import { d as parseChannelLink, f as secretFromTopic, o as deriveChannelId, s as deriveRoom } from "./channels-BiGUYTuz.js";
|
|
3
|
+
import { a as renderThread, c as makeOp, f as hlcSend, n as maxHlc, o as sortOps, r as mergeOps, s as isValidOp } from "./store-Ck0XRn-K.js";
|
|
4
|
+
import { t as ChannelPeer } from "./peer-B5JKF4BP.js";
|
|
5
|
+
|
|
6
|
+
//#region ts/channels/store.browser.ts
|
|
7
|
+
const PREFIX = "ay29ch:";
|
|
8
|
+
var LocalStorageStore = class {
|
|
9
|
+
key;
|
|
10
|
+
constructor(channelId, storage = globalThis.localStorage) {
|
|
11
|
+
this.storage = storage;
|
|
12
|
+
this.key = PREFIX + channelId;
|
|
13
|
+
}
|
|
14
|
+
read() {
|
|
15
|
+
try {
|
|
16
|
+
const raw = this.storage.getItem(this.key);
|
|
17
|
+
if (!raw) return [];
|
|
18
|
+
const arr = JSON.parse(raw);
|
|
19
|
+
return sortOps((Array.isArray(arr) ? arr : []).filter(isValidOp));
|
|
20
|
+
} catch {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
all() {
|
|
25
|
+
return Promise.resolve(this.read());
|
|
26
|
+
}
|
|
27
|
+
append(ops) {
|
|
28
|
+
const { merged, added } = mergeOps(this.read(), ops.filter(isValidOp));
|
|
29
|
+
if (added.length) this.storage.setItem(this.key, JSON.stringify(merged));
|
|
30
|
+
return Promise.resolve(added);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region ts/channels/browser.ts
|
|
36
|
+
var AyChannel = class AyChannel {
|
|
37
|
+
room;
|
|
38
|
+
sighost;
|
|
39
|
+
s;
|
|
40
|
+
channelId = "";
|
|
41
|
+
name;
|
|
42
|
+
role;
|
|
43
|
+
author = "";
|
|
44
|
+
store;
|
|
45
|
+
peer;
|
|
46
|
+
listeners = /* @__PURE__ */ new Map();
|
|
47
|
+
started = false;
|
|
48
|
+
peers = 0;
|
|
49
|
+
/**
|
|
50
|
+
* Build a channel whose identity is DERIVED from a topic string (e.g. the page
|
|
51
|
+
* URL) — same topic ⇒ same room, no invite needed. Public to anyone with the
|
|
52
|
+
* topic (see secretFromTopic). This is what the page bookmarklet uses.
|
|
53
|
+
*/
|
|
54
|
+
static async fromTopic(topic, opts) {
|
|
55
|
+
const s = await secretFromTopic(topic);
|
|
56
|
+
const sighost = opts?.sighost ?? "s.agent-yes.com";
|
|
57
|
+
return new AyChannel({
|
|
58
|
+
room: await deriveRoom(s),
|
|
59
|
+
sighost,
|
|
60
|
+
s,
|
|
61
|
+
name: opts?.name,
|
|
62
|
+
role: opts?.role
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
constructor(info) {
|
|
66
|
+
const o = typeof info === "string" ? { link: info } : info;
|
|
67
|
+
const link = o.link ? parseChannelLink(o.link) : null;
|
|
68
|
+
this.room = o.room ?? link?.room ?? "";
|
|
69
|
+
this.sighost = o.sighost ?? link?.sighost ?? "s.agent-yes.com";
|
|
70
|
+
this.s = o.s ?? link?.s ?? "";
|
|
71
|
+
if (!this.room || !this.s) throw new Error("AyChannel: need a link or {room, s}");
|
|
72
|
+
this.name = o.name ?? "guest";
|
|
73
|
+
this.role = o.role ?? "human";
|
|
74
|
+
if (o.author) this.author = o.author;
|
|
75
|
+
}
|
|
76
|
+
/** Derive identity, open the LocalStorage replica, and join the mesh. */
|
|
77
|
+
async start() {
|
|
78
|
+
if (this.started) return;
|
|
79
|
+
this.started = true;
|
|
80
|
+
this.channelId = await deriveChannelId(this.s);
|
|
81
|
+
this.store = new LocalStorageStore(this.channelId);
|
|
82
|
+
this.loadIdentity();
|
|
83
|
+
this.peer = new ChannelPeer({
|
|
84
|
+
room: this.room,
|
|
85
|
+
sighost: this.sighost,
|
|
86
|
+
s: this.s,
|
|
87
|
+
rtc: globalThis.RTCPeerConnection,
|
|
88
|
+
WebSocketImpl: globalThis.WebSocket,
|
|
89
|
+
store: this.store,
|
|
90
|
+
onOp: () => this.emit("message", void 0),
|
|
91
|
+
onPeers: (n) => {
|
|
92
|
+
this.peers = n;
|
|
93
|
+
this.emit("peers", n);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
await this.peer.start();
|
|
97
|
+
this.emit("ready", void 0);
|
|
98
|
+
}
|
|
99
|
+
/** Identity is stable per channel across reloads (a returning tab keeps its author id). */
|
|
100
|
+
loadIdentity() {
|
|
101
|
+
const key = `ay29ch-id:${this.channelId}`;
|
|
102
|
+
let saved = null;
|
|
103
|
+
try {
|
|
104
|
+
saved = JSON.parse(localStorage.getItem(key) || "null");
|
|
105
|
+
} catch {}
|
|
106
|
+
this.author ||= saved?.author || randomHex(8);
|
|
107
|
+
if (saved?.name && this.name === "guest") this.name = saved.name;
|
|
108
|
+
if (saved?.role && this.role === "human") this.role = saved.role;
|
|
109
|
+
try {
|
|
110
|
+
localStorage.setItem(key, JSON.stringify({
|
|
111
|
+
author: this.author,
|
|
112
|
+
name: this.name,
|
|
113
|
+
role: this.role
|
|
114
|
+
}));
|
|
115
|
+
} catch {}
|
|
116
|
+
}
|
|
117
|
+
/** The rendered thread (folded messages, ordered). */
|
|
118
|
+
async messages() {
|
|
119
|
+
return renderThread(await (this.store?.all() ?? Promise.resolve([])));
|
|
120
|
+
}
|
|
121
|
+
/** The current confirmed-peer count (presence). */
|
|
122
|
+
peerCount() {
|
|
123
|
+
return this.peers;
|
|
124
|
+
}
|
|
125
|
+
/** Post a message: persist locally + broadcast to the mesh. */
|
|
126
|
+
async send(text) {
|
|
127
|
+
if (!this.store || !this.peer) throw new Error("AyChannel: call start() first");
|
|
128
|
+
const t = text.trim();
|
|
129
|
+
if (!t) return;
|
|
130
|
+
const hlc = hlcSend(maxHlc(await this.store.all()), Date.now(), this.author);
|
|
131
|
+
const op = makeOp({
|
|
132
|
+
author: this.author,
|
|
133
|
+
name: this.name,
|
|
134
|
+
role: this.role,
|
|
135
|
+
hlc,
|
|
136
|
+
kind: "msg",
|
|
137
|
+
body: t
|
|
138
|
+
});
|
|
139
|
+
await this.peer.publish(op);
|
|
140
|
+
this.emit("message", void 0);
|
|
141
|
+
}
|
|
142
|
+
on(evt, cb) {
|
|
143
|
+
(this.listeners.get(evt) ?? this.listeners.set(evt, /* @__PURE__ */ new Set()).get(evt)).add(cb);
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
off(evt, cb) {
|
|
147
|
+
this.listeners.get(evt)?.delete(cb);
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
emit(evt, arg) {
|
|
151
|
+
for (const cb of this.listeners.get(evt) ?? []) try {
|
|
152
|
+
cb(arg);
|
|
153
|
+
} catch {}
|
|
154
|
+
}
|
|
155
|
+
close() {
|
|
156
|
+
this.peer?.close();
|
|
157
|
+
this.widget?.remove();
|
|
158
|
+
}
|
|
159
|
+
widget;
|
|
160
|
+
labelKey() {
|
|
161
|
+
return `ay29ch-label:${this.room}`;
|
|
162
|
+
}
|
|
163
|
+
defaultLabel() {
|
|
164
|
+
return this.room ? this.room.slice(0, 14) : "Channel";
|
|
165
|
+
}
|
|
166
|
+
loadLabel() {
|
|
167
|
+
try {
|
|
168
|
+
return localStorage.getItem(this.labelKey()) || this.defaultLabel();
|
|
169
|
+
} catch {
|
|
170
|
+
return this.defaultLabel();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
saveLabel(v) {
|
|
174
|
+
try {
|
|
175
|
+
localStorage.setItem(this.labelKey(), v.trim() || this.defaultLabel());
|
|
176
|
+
} catch {}
|
|
177
|
+
}
|
|
178
|
+
/** Door icon → prompt for another channel (topic or invite link) and switch to it. */
|
|
179
|
+
async joinAnother(parent) {
|
|
180
|
+
const g = globalThis;
|
|
181
|
+
const input = g.prompt?.("Join a channel — topic or invite link:", "");
|
|
182
|
+
if (!input) return;
|
|
183
|
+
const isLink = input.startsWith("ay://") || input.includes("#ch=");
|
|
184
|
+
let next;
|
|
185
|
+
try {
|
|
186
|
+
next = isLink ? new AyChannel({
|
|
187
|
+
link: input,
|
|
188
|
+
name: this.name,
|
|
189
|
+
role: this.role
|
|
190
|
+
}) : await AyChannel.fromTopic(input, {
|
|
191
|
+
sighost: this.sighost,
|
|
192
|
+
name: this.name,
|
|
193
|
+
role: this.role
|
|
194
|
+
});
|
|
195
|
+
} catch (e) {
|
|
196
|
+
g.alert?.("Could not join: " + (e?.message || e));
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
this.close();
|
|
200
|
+
await next.start();
|
|
201
|
+
next.mount(parent, { open: true });
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Render the floating chat window. With no target it mounts a fixed-position
|
|
205
|
+
* bubble in the corner; pass an element to embed it there. Auto-calls start().
|
|
206
|
+
*/
|
|
207
|
+
mount(target, opts) {
|
|
208
|
+
if (this.widget) return this.widget;
|
|
209
|
+
const doc = globalThis.document;
|
|
210
|
+
const host = doc.createElement("div");
|
|
211
|
+
host.setAttribute("data-aychannel", this.channelId || this.room);
|
|
212
|
+
const root = host.attachShadow({ mode: "open" });
|
|
213
|
+
root.innerHTML = WIDGET_HTML;
|
|
214
|
+
this.widget = host;
|
|
215
|
+
(target ?? doc.body).appendChild(host);
|
|
216
|
+
const list = root.getElementById("list");
|
|
217
|
+
const input = root.getElementById("input");
|
|
218
|
+
const form = root.getElementById("form");
|
|
219
|
+
const badge = root.getElementById("peers");
|
|
220
|
+
const panel = root.getElementById("panel");
|
|
221
|
+
const toggle = root.getElementById("toggle");
|
|
222
|
+
const chname = root.getElementById("chname");
|
|
223
|
+
const door = root.getElementById("door");
|
|
224
|
+
const parent = target ?? doc.body;
|
|
225
|
+
chname.value = this.loadLabel();
|
|
226
|
+
chname.addEventListener("change", () => this.saveLabel(chname.value));
|
|
227
|
+
door.addEventListener("click", () => void this.joinAnother(parent));
|
|
228
|
+
const esc = (s) => s.replace(/[&<>"]/g, (c) => ({
|
|
229
|
+
"&": "&",
|
|
230
|
+
"<": "<",
|
|
231
|
+
">": ">",
|
|
232
|
+
"\"": """
|
|
233
|
+
})[c]);
|
|
234
|
+
const render = async () => {
|
|
235
|
+
list.innerHTML = (await this.messages()).map((m) => {
|
|
236
|
+
const mine = m.author === this.author;
|
|
237
|
+
const time = new Date(m.ms).toLocaleTimeString([], {
|
|
238
|
+
hour: "2-digit",
|
|
239
|
+
minute: "2-digit"
|
|
240
|
+
});
|
|
241
|
+
const body = m.deleted ? "<i>message deleted</i>" : esc(m.text);
|
|
242
|
+
return `<div class="msg ${mine ? "mine" : ""} ${m.role}"><div class="meta">${esc(m.name)} · ${time}</div><div class="body">${body}</div></div>`;
|
|
243
|
+
}).join("");
|
|
244
|
+
list.scrollTop = list.scrollHeight;
|
|
245
|
+
};
|
|
246
|
+
form.addEventListener("submit", (e) => {
|
|
247
|
+
e.preventDefault();
|
|
248
|
+
const text = input.value;
|
|
249
|
+
input.value = "";
|
|
250
|
+
this.send(text);
|
|
251
|
+
});
|
|
252
|
+
toggle.addEventListener("click", () => panel.classList.toggle("open"));
|
|
253
|
+
if (opts?.open) panel.classList.add("open");
|
|
254
|
+
this.on("message", () => void render());
|
|
255
|
+
this.on("peers", () => badge.textContent = String(this.peers));
|
|
256
|
+
(async () => {
|
|
257
|
+
if (!this.started) await this.start();
|
|
258
|
+
await render();
|
|
259
|
+
badge.textContent = String(this.peers);
|
|
260
|
+
})();
|
|
261
|
+
return host;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
const WIDGET_HTML = `
|
|
265
|
+
<style>
|
|
266
|
+
:host { all: initial; }
|
|
267
|
+
* { box-sizing: border-box; font-family: system-ui, -apple-system, sans-serif; }
|
|
268
|
+
#toggle {
|
|
269
|
+
position: fixed; right: 20px; bottom: 20px; z-index: 2147483000;
|
|
270
|
+
width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
|
|
271
|
+
background: #4f46e5; color: #fff; font-size: 22px; box-shadow: 0 4px 16px rgba(0,0,0,.3);
|
|
272
|
+
}
|
|
273
|
+
#panel {
|
|
274
|
+
position: fixed; right: 20px; bottom: 84px; z-index: 2147483000;
|
|
275
|
+
width: min(360px, 92vw); height: min(520px, 70vh); display: none;
|
|
276
|
+
flex-direction: column; background: #1b1d24; color: #e6e6ea; border-radius: 14px;
|
|
277
|
+
box-shadow: 0 12px 40px rgba(0,0,0,.45); overflow: hidden; border: 1px solid #2c2f3a;
|
|
278
|
+
}
|
|
279
|
+
#panel.open { display: flex; }
|
|
280
|
+
header { padding: 10px 12px; background: #23262f; display: flex; align-items: center; gap: 6px; }
|
|
281
|
+
header .chname { flex: 1; min-width: 0; background: transparent; border: none; color: #e6e6ea; font-weight: 600; font-size: 14px; padding: 3px 5px; border-radius: 6px; }
|
|
282
|
+
header .chname:focus { outline: none; background: #2c2f3a; }
|
|
283
|
+
header .door { background: transparent; border: none; cursor: pointer; font-size: 15px; padding: 2px 4px; opacity: .75; }
|
|
284
|
+
header .door:hover { opacity: 1; }
|
|
285
|
+
header .peers { font-size: 12px; opacity: .8; background: #4f46e5; border-radius: 10px; padding: 1px 8px; }
|
|
286
|
+
#list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
|
|
287
|
+
.msg { max-width: 82%; }
|
|
288
|
+
.msg .meta { font-size: 11px; opacity: .6; margin-bottom: 2px; }
|
|
289
|
+
.msg .body { background: #2c2f3a; padding: 7px 10px; border-radius: 10px; font-size: 13px; line-height: 1.35; white-space: pre-wrap; word-break: break-word; }
|
|
290
|
+
.msg.agent .body { border-left: 3px solid #10b981; }
|
|
291
|
+
.msg.mine { align-self: flex-end; text-align: right; }
|
|
292
|
+
.msg.mine .body { background: #4f46e5; color: #fff; }
|
|
293
|
+
#form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid #2c2f3a; }
|
|
294
|
+
#input { flex: 1; background: #23262f; border: 1px solid #363a46; color: #e6e6ea; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
|
|
295
|
+
#form button { background: #4f46e5; color: #fff; border: none; border-radius: 8px; padding: 0 14px; cursor: pointer; font-size: 13px; }
|
|
296
|
+
</style>
|
|
297
|
+
<button id="toggle" title="Chat">💬</button>
|
|
298
|
+
<section id="panel">
|
|
299
|
+
<header>
|
|
300
|
+
<input id="chname" class="chname" spellcheck="false" title="Channel name (editable)" />
|
|
301
|
+
<button id="door" class="door" title="Join another channel">🚪</button>
|
|
302
|
+
<span class="peers" id="peers" title="peers online">0</span>
|
|
303
|
+
</header>
|
|
304
|
+
<div id="list"></div>
|
|
305
|
+
<form id="form"><input id="input" placeholder="Message…" autocomplete="off" /><button type="submit">Send</button></form>
|
|
306
|
+
</section>
|
|
307
|
+
`;
|
|
308
|
+
|
|
309
|
+
//#endregion
|
|
310
|
+
export { AyChannel as t };
|
|
311
|
+
//# sourceMappingURL=browser-B3dOptjL.js.map
|