@elefunc/send 0.1.12 → 0.1.13
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 +1 -1
- package/src/index.ts +7 -6
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { resolve } from "node:path"
|
|
3
3
|
import { cac, type CAC } from "cac"
|
|
4
|
-
import { cleanRoom } from "./core/protocol"
|
|
4
|
+
import { cleanRoom, displayPeerName } from "./core/protocol"
|
|
5
5
|
import type { SendSession, SessionConfig, SessionEvent } from "./core/session"
|
|
6
6
|
import { resolvePeerTargets } from "./core/targeting"
|
|
7
7
|
import { ensureSessionRuntimePatches, ensureTuiRuntimePatches } from "../runtime/install"
|
|
@@ -108,9 +108,10 @@ export const sessionConfigFrom = (options: Record<string, unknown>, defaults: {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
export const roomAnnouncement = (room: string, json = false) =>
|
|
111
|
+
export const roomAnnouncement = (room: string, self: string, json = false) =>
|
|
112
|
+
json ? JSON.stringify({ type: "room", room, self }) : `room ${room}\nself ${self}`
|
|
112
113
|
|
|
113
|
-
const printRoomAnnouncement = (room: string, json = false) => console.log(roomAnnouncement(room, json))
|
|
114
|
+
const printRoomAnnouncement = (room: string, self: string, json = false) => console.log(roomAnnouncement(room, self, json))
|
|
114
115
|
|
|
115
116
|
const printEvent = (event: SessionEvent) => console.log(JSON.stringify(event))
|
|
116
117
|
|
|
@@ -191,7 +192,7 @@ const peersCommand = async (options: Record<string, unknown>) => {
|
|
|
191
192
|
const { SendSession } = await loadSessionRuntime()
|
|
192
193
|
const session = new SendSession(sessionConfigFrom(options, {}))
|
|
193
194
|
handleSignals(session)
|
|
194
|
-
printRoomAnnouncement(session.room, !!options.json)
|
|
195
|
+
printRoomAnnouncement(session.room, displayPeerName(session.name, session.localId), !!options.json)
|
|
195
196
|
await session.connect()
|
|
196
197
|
await Bun.sleep(numberOption(options.wait, 3000))
|
|
197
198
|
const snapshot = session.snapshot()
|
|
@@ -218,7 +219,7 @@ const offerCommand = async (files: string[], options: Record<string, unknown>) =
|
|
|
218
219
|
const { SendSession } = await loadSessionRuntime()
|
|
219
220
|
const session = new SendSession(sessionConfigFrom(options, {}))
|
|
220
221
|
handleSignals(session)
|
|
221
|
-
printRoomAnnouncement(session.room, !!options.json)
|
|
222
|
+
printRoomAnnouncement(session.room, displayPeerName(session.name, session.localId), !!options.json)
|
|
222
223
|
const detachReporter = attachReporter(session, !!options.json)
|
|
223
224
|
await session.connect()
|
|
224
225
|
const targets = await waitForTargets(session, selectors, timeoutMs)
|
|
@@ -234,7 +235,7 @@ const acceptCommand = async (options: Record<string, unknown>) => {
|
|
|
234
235
|
const { SendSession } = await loadSessionRuntime()
|
|
235
236
|
const session = new SendSession(sessionConfigFrom(options, { autoAcceptIncoming: true, autoSaveIncoming: true }))
|
|
236
237
|
handleSignals(session)
|
|
237
|
-
printRoomAnnouncement(session.room, !!options.json)
|
|
238
|
+
printRoomAnnouncement(session.room, displayPeerName(session.name, session.localId), !!options.json)
|
|
238
239
|
const detachReporter = attachReporter(session, !!options.json)
|
|
239
240
|
await session.connect()
|
|
240
241
|
if (!options.json) console.log(`listening in ${session.room}`)
|