@ghostlytools/cli 1.4.1 → 1.4.3
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/README.md +5 -2
- package/dist/assets/{api-JMkEO0RR.js → api-PWMQJGFi.js} +59 -14
- package/dist/assets/api-PWMQJGFi.js.map +1 -0
- package/dist/assets/{api-BqLfti32.js → api-r2Nd4r19.js} +2 -2
- package/dist/assets/{apiKit-BpIUCwa-.js → apiKit-qLBXqv02.js} +2 -2
- package/dist/assets/{apiKit-BpIUCwa-.js.map → apiKit-qLBXqv02.js.map} +1 -1
- package/dist/assets/{apps-Bettj7WQ.js → apps-0XIzvlZk.js} +2 -2
- package/dist/assets/{apps-Bettj7WQ.js.map → apps-0XIzvlZk.js.map} +1 -1
- package/dist/assets/{apps-BdfyGVZ1.js → apps-DD9tZdFb.js} +1 -1
- package/dist/assets/{arkade-CP4HvKaa.js → arkade-BSmaMO_Y.js} +2 -2
- package/dist/assets/{arkade-CP4HvKaa.js.map → arkade-BSmaMO_Y.js.map} +1 -1
- package/dist/assets/{backup-BmBtta66.js → backup-DhO7RbYO.js} +4 -4
- package/dist/assets/{backup-BmBtta66.js.map → backup-DhO7RbYO.js.map} +1 -1
- package/dist/assets/{backup-BbO2zLjx.js → backup-LNFuInyF.js} +1 -1
- package/dist/assets/{buttons-YgijrprJ.js → buttons-BRkpVMtD.js} +3 -3
- package/dist/assets/{buttons-YgijrprJ.js.map → buttons-BRkpVMtD.js.map} +1 -1
- package/dist/assets/buttons-BjVhIyPp.js +2 -0
- package/dist/assets/{envelope-C7vnmsJN.js → envelope-DGu2538X.js} +2 -2
- package/dist/assets/{envelope-C7vnmsJN.js.map → envelope-DGu2538X.js.map} +1 -1
- package/dist/assets/{groupFiles-sIdGq4AV.js → groupFiles-BWlfYs84.js} +4 -4
- package/dist/assets/{groupFiles-sIdGq4AV.js.map → groupFiles-BWlfYs84.js.map} +1 -1
- package/dist/assets/{host-BMCiIXsq.js → host-bGuDUvo3.js} +81 -26
- package/dist/assets/host-bGuDUvo3.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-BNnOyzKP.js → hyperdhtRelay-DWQV9iZG.js} +2 -2
- package/dist/assets/{hyperdhtRelay-BNnOyzKP.js.map → hyperdhtRelay-DWQV9iZG.js.map} +1 -1
- package/dist/assets/{irohWeb-DHCxSvHF.js → irohWeb-DCx_4wdP.js} +2 -2
- package/dist/assets/{irohWeb-DHCxSvHF.js.map → irohWeb-DCx_4wdP.js.map} +1 -1
- package/dist/assets/{main-Duiz7jTN.js → main-DymrMP6q.js} +21 -19
- package/dist/assets/main-DymrMP6q.js.map +1 -0
- package/dist/assets/{mainline-CsG-DdJ5.js → mainline-BI-TebeH.js} +2 -2
- package/dist/assets/{mainline-CsG-DdJ5.js.map → mainline-BI-TebeH.js.map} +1 -1
- package/dist/assets/{networkReason-B91upMCb.js → networkReason-DuKI3ATs.js} +2 -2
- package/dist/assets/{networkReason-B91upMCb.js.map → networkReason-DuKI3ATs.js.map} +1 -1
- package/dist/assets/{nwc-BFv67iSz.js → nwc-DcAovoOM.js} +3 -3
- package/dist/assets/{nwc-BFv67iSz.js.map → nwc-DcAovoOM.js.map} +1 -1
- package/dist/assets/{nwcProvider-BKNFdH9v.js → nwcProvider-LZGgbf5h.js} +2 -2
- package/dist/assets/{nwcProvider-BKNFdH9v.js.map → nwcProvider-LZGgbf5h.js.map} +1 -1
- package/dist/assets/{registry-CHPd_hf7.js → registry-D1qVtZzw.js} +1 -1
- package/dist/assets/{registry-qbnWmwCE.js → registry-KPRUnCeJ.js} +3 -3
- package/dist/assets/{registry-qbnWmwCE.js.map → registry-KPRUnCeJ.js.map} +1 -1
- package/dist/assets/{resolve-B63_uSu7.js → resolve-DYRousKD.js} +2 -2
- package/dist/assets/{resolve-B63_uSu7.js.map → resolve-DYRousKD.js.map} +1 -1
- package/dist/assets/{server-BS1gbvxG.js → server-VMriom5-.js} +12 -12
- package/dist/assets/{server-BS1gbvxG.js.map → server-VMriom5-.js.map} +1 -1
- package/dist/assets/{src-DzXL-GYu.js → src-D7v4sfDf.js} +6 -1
- package/dist/assets/{src-DzXL-GYu.js.map → src-D7v4sfDf.js.map} +1 -1
- package/dist/assets/{turnRefs-BCtM10d3.js → turnRefs-BvHvaNjv.js} +2 -2
- package/dist/assets/{turnRefs-BCtM10d3.js.map → turnRefs-BvHvaNjv.js.map} +1 -1
- package/dist/assets/{usdt-B7JWDhQV.js → usdt-06Ou18lB.js} +3 -3
- package/dist/assets/{usdt-B7JWDhQV.js.map → usdt-06Ou18lB.js.map} +1 -1
- package/dist/ghostly.mjs +1 -1
- package/package.json +1 -1
- package/dist/assets/api-JMkEO0RR.js.map +0 -1
- package/dist/assets/buttons-_GBlxAti.js +0 -2
- package/dist/assets/host-BMCiIXsq.js.map +0 -1
- package/dist/assets/main-Duiz7jTN.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Ao as signalHasVideo, Co as RTC_CONFIG, Do as callSignalHeardAt, Eo as callRtcConfig, Oo as extractParamsFromSdp, So as CALL_SIGNAL_MAX_AGE_MS, To as buildSdpFromSignal, Xr as checkPushEndpoint, Zl as fromBase64Url, bi as isPublicAddress, jl as setLinkTraceSink, ko as parseCallSignal, wo as answersOffer } from "./src-
|
|
2
|
-
import { a as fedimintSdkOn, r as irohRelayProblem } from "./irohWeb-
|
|
1
|
+
import { Ao as signalHasVideo, Co as RTC_CONFIG, Do as callSignalHeardAt, Eo as callRtcConfig, Oo as extractParamsFromSdp, So as CALL_SIGNAL_MAX_AGE_MS, To as buildSdpFromSignal, Xr as checkPushEndpoint, Zl as fromBase64Url, bi as isPublicAddress, jl as setLinkTraceSink, ko as parseCallSignal, wo as answersOffer } from "./src-D7v4sfDf.js";
|
|
2
|
+
import { a as fedimintSdkOn, r as irohRelayProblem } from "./irohWeb-DCx_4wdP.js";
|
|
3
3
|
import { r as asCliError, t as CliError } from "./errors-BLSPp0tK.js";
|
|
4
|
-
import { a as findChat } from "./apiKit-
|
|
5
|
-
import { _ as flushCardUpdates, c as paymentJson, d as nodeLocalFetch, f as chatJson, g as resumeHolds, h as groupMessageJson, l as reportAppFrames, m as groupJson, p as chatMessageJson, r as callApi, u as servedApps } from "./api-
|
|
4
|
+
import { a as findChat } from "./apiKit-qLBXqv02.js";
|
|
5
|
+
import { _ as flushCardUpdates, c as paymentJson, d as nodeLocalFetch, f as chatJson, g as resumeHolds, h as groupMessageJson, l as reportAppFrames, m as groupJson, p as chatMessageJson, r as callApi, u as servedApps } from "./api-PWMQJGFi.js";
|
|
6
6
|
import { n as RESTORED_MARK, r as acquireLock } from "./profiles-DSxPYdlU.js";
|
|
7
7
|
import { i as proof, l as privateFolder, n as newDaemonSecret, s as ownFolder } from "./daemonProof-B53VnZ1Z.js";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
@@ -1660,6 +1660,11 @@ function readAuto(path) {
|
|
|
1660
1660
|
}
|
|
1661
1661
|
/** A journal past this is trimmed, and only this much of its end is ever read. */
|
|
1662
1662
|
var JOURNAL_MAX_BYTES = 33554432;
|
|
1663
|
+
/**
|
|
1664
|
+
* Up to this many ids removed at once, the journal's bytes are searched for each (`forget`); more are matched against
|
|
1665
|
+
* each line once, read whole: 2,000 ids searched line by line held a daemon 12 s on a journal of 10,000 events.
|
|
1666
|
+
*/
|
|
1667
|
+
var FORGET_SEARCHED_IDS = 16;
|
|
1663
1668
|
var SEEN_DB = "ghostly-cli";
|
|
1664
1669
|
var SEEN = "seen";
|
|
1665
1670
|
/**
|
|
@@ -1937,27 +1942,51 @@ var EventHub = class {
|
|
|
1937
1942
|
/**
|
|
1938
1943
|
* What was removed here leaves the journal too: the journal is written again without the events that name it (a
|
|
1939
1944
|
* line that names it and cannot be read goes as well), and a journal set aside as unreadable, which cannot be sorted,
|
|
1940
|
-
* is deleted. `ids`: what was removed (a message's id, a chat's or a group's); `gone`: whether an event is of it
|
|
1945
|
+
* is deleted. `ids`: what was removed (a message's id, a chat's or a group's); `gone`: whether an event is of it;
|
|
1946
|
+
* `unquote`: an event that stays, written again without what it quotes of the removed (a reply's event), else none.
|
|
1941
1947
|
*/
|
|
1942
|
-
forget(ids, gone) {
|
|
1948
|
+
forget(ids, gone, unquote = () => void 0) {
|
|
1943
1949
|
if (!ids.length) return;
|
|
1944
1950
|
try {
|
|
1945
1951
|
rmSync(this.journalPath + ".unreadable", { force: true });
|
|
1946
1952
|
if (!existsSync(this.journalPath)) return;
|
|
1947
|
-
const
|
|
1948
|
-
const
|
|
1949
|
-
|
|
1953
|
+
const { bytes, start } = journalWindow(this.journalPath);
|
|
1954
|
+
const needles = ids.map((id) => JSON.stringify(id)), few = ids.length <= FORGET_SEARCHED_IDS;
|
|
1955
|
+
const names = (line) => needles.some((needle) => line.includes(needle));
|
|
1956
|
+
let from = few ? bytes.length : start;
|
|
1957
|
+
if (few) for (const needle of needles) {
|
|
1958
|
+
const at = bytes.indexOf(needle, start);
|
|
1959
|
+
if (at !== -1 && at < from) from = at;
|
|
1960
|
+
}
|
|
1961
|
+
if (from === bytes.length) return;
|
|
1962
|
+
from = Math.max(start, bytes.lastIndexOf(10, from) + 1);
|
|
1963
|
+
const lines = bytes.toString("utf8", from).split("\n").filter(Boolean);
|
|
1964
|
+
let changed = false;
|
|
1965
|
+
const kept = lines.flatMap((line) => {
|
|
1966
|
+
if (few && !names(line)) return [line];
|
|
1967
|
+
let event;
|
|
1950
1968
|
try {
|
|
1951
|
-
|
|
1969
|
+
event = JSON.parse(line);
|
|
1952
1970
|
} catch {
|
|
1953
|
-
return
|
|
1971
|
+
if (!few && !names(line)) return [line];
|
|
1972
|
+
changed = true;
|
|
1973
|
+
return [];
|
|
1954
1974
|
}
|
|
1975
|
+
if (gone(event)) {
|
|
1976
|
+
changed = true;
|
|
1977
|
+
return [];
|
|
1978
|
+
}
|
|
1979
|
+
const written = unquote(event);
|
|
1980
|
+
if (!written) return [line];
|
|
1981
|
+
changed = true;
|
|
1982
|
+
return [JSON.stringify(written)];
|
|
1955
1983
|
});
|
|
1956
|
-
if (
|
|
1957
|
-
|
|
1984
|
+
if (!changed) return;
|
|
1985
|
+
const tail = kept.length ? kept.join("\n") + "\n" : "";
|
|
1986
|
+
writeFileSync(this.journalPath + ".tmp", Buffer.concat([bytes.subarray(start, from), Buffer.from(tail)]), { mode: 384 });
|
|
1958
1987
|
renameSync(this.journalPath + ".tmp", this.journalPath);
|
|
1959
|
-
this.journalLines
|
|
1960
|
-
this.journalBytes =
|
|
1988
|
+
this.journalLines -= lines.length - kept.length;
|
|
1989
|
+
this.journalBytes = from - start + Buffer.byteLength(tail);
|
|
1961
1990
|
} catch (error) {
|
|
1962
1991
|
process.stderr.write(`ghostly: event journal error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
1963
1992
|
}
|
|
@@ -2042,7 +2071,8 @@ var EventHub = class {
|
|
|
2042
2071
|
this.chats.delete(id);
|
|
2043
2072
|
if (!quiet) this.emit("chat.removed", `chat.removed:${id}`, { chat: id });
|
|
2044
2073
|
}
|
|
2045
|
-
|
|
2074
|
+
const chatsGone = new Set(removedChats);
|
|
2075
|
+
this.forget(removedChats, (event) => chatsGone.has(event.chat) && event.type !== "chat.removed");
|
|
2046
2076
|
const groups = new Map(state.groups.map((group) => [group.id, group]));
|
|
2047
2077
|
for (const [id, group] of groups) {
|
|
2048
2078
|
const shape = groupShape(group), before = this.groups.get(id);
|
|
@@ -2086,7 +2116,8 @@ var EventHub = class {
|
|
|
2086
2116
|
this.groups.delete(id);
|
|
2087
2117
|
if (!quiet) this.emit("group.removed", `group.removed:${id}`, { group: id });
|
|
2088
2118
|
}
|
|
2089
|
-
|
|
2119
|
+
const groupsGone = new Set(removedGroups);
|
|
2120
|
+
this.forget(removedGroups, (event) => groupsGone.has(event.group) && event.type !== "group.removed");
|
|
2090
2121
|
for (const [id, payment] of Object.entries(state.payments ?? {})) {
|
|
2091
2122
|
const shape = `${payment.state}|${payment.error ?? ""}|${payment.closed ? 1 : 0}`, before = this.payments.get(id);
|
|
2092
2123
|
this.payments.set(id, shape);
|
|
@@ -2356,8 +2387,24 @@ var EventHub = class {
|
|
|
2356
2387
|
});
|
|
2357
2388
|
}
|
|
2358
2389
|
if (changes.length) this.persist(chat, changes);
|
|
2359
|
-
const whole = !!group && !deleted && messages.length === 0 && gone.length > 0;
|
|
2360
|
-
|
|
2390
|
+
const whole = !!group && !deleted && messages.length === 0 && gone.length > 0, goneIds = new Set(gone);
|
|
2391
|
+
const here = (event) => group ? event.group === group : event.chat === chat;
|
|
2392
|
+
this.forget(whole ? [group] : gone, (event) => here(event) && !event.type.endsWith(".deleted") && (whole ? "message" in event || "messageId" in event || "replyId" in event : goneIds.has(event.messageId) || goneIds.has(event.message?.id) || goneIds.has(event.replyId)), (event) => {
|
|
2393
|
+
const message = event.message;
|
|
2394
|
+
if (whole || !here(event) || !message?.replyTo || !goneIds.has(message.replyTo.id) || message.replyTo.deleted) return;
|
|
2395
|
+
return {
|
|
2396
|
+
...event,
|
|
2397
|
+
message: {
|
|
2398
|
+
...message,
|
|
2399
|
+
replyTo: {
|
|
2400
|
+
...message.replyTo,
|
|
2401
|
+
snippet: "",
|
|
2402
|
+
found: false,
|
|
2403
|
+
deleted: true
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
};
|
|
2407
|
+
});
|
|
2361
2408
|
for (const [fileId, messageId] of files) this.flushFile(fileId, messageId);
|
|
2362
2409
|
}
|
|
2363
2410
|
/**
|
|
@@ -2529,6 +2576,14 @@ function groupShape(group) {
|
|
|
2529
2576
|
* a journal grown past what a string can hold (or a trim's bound) is still read, and in bounded time.
|
|
2530
2577
|
*/
|
|
2531
2578
|
function journalTail(path) {
|
|
2579
|
+
const { bytes, start, size } = journalWindow(path);
|
|
2580
|
+
return {
|
|
2581
|
+
lines: bytes.toString("utf8", start).split("\n").filter(Boolean),
|
|
2582
|
+
size
|
|
2583
|
+
};
|
|
2584
|
+
}
|
|
2585
|
+
/** The bytes of the journal's last `JOURNAL_MAX_BYTES`, `start` where its first whole line begins in them, and its size. */
|
|
2586
|
+
function journalWindow(path) {
|
|
2532
2587
|
const fd = openSync(path, "r");
|
|
2533
2588
|
try {
|
|
2534
2589
|
const size = fstatSync(fd).size;
|
|
@@ -2540,10 +2595,10 @@ function journalTail(path) {
|
|
|
2540
2595
|
if (!n) break;
|
|
2541
2596
|
read += n;
|
|
2542
2597
|
}
|
|
2543
|
-
const
|
|
2544
|
-
if (from > 0) lines.shift();
|
|
2598
|
+
const bytes = buffer.subarray(0, read);
|
|
2545
2599
|
return {
|
|
2546
|
-
|
|
2600
|
+
bytes,
|
|
2601
|
+
start: from > 0 ? bytes.indexOf(10) + 1 || bytes.length : 0,
|
|
2547
2602
|
size
|
|
2548
2603
|
};
|
|
2549
2604
|
} finally {
|
|
@@ -4722,14 +4777,14 @@ async function startRuntime(paths, options = {}) {
|
|
|
4722
4777
|
const [{ registerFileBytes }, { NodeFileBytes }] = await Promise.all([import("./fileBytes-C2jycN_7.js"), import("./fileBytes-D6fqFQEX.js")]);
|
|
4723
4778
|
registerFileBytes("native", async () => new NodeFileBytes(paths.files), true);
|
|
4724
4779
|
if (await (await import("./blobFiles-B0rNnHlO.js")).moveBlobFiles()) await store.compact();
|
|
4725
|
-
const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-
|
|
4780
|
+
const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-VMriom5-.js"), import("./endpoint-Cl3cgAYl.js")]);
|
|
4726
4781
|
const network = hyperdhtNetwork();
|
|
4727
4782
|
const dht = mainlineNetwork();
|
|
4728
|
-
const mainline = dht.off ? null : new (await (import("./mainline-
|
|
4783
|
+
const mainline = dht.off ? null : new (await (import("./mainline-BI-TebeH.js"))).Mainline({
|
|
4729
4784
|
bootstrap: dht.bootstrap,
|
|
4730
4785
|
host: dht.host
|
|
4731
4786
|
});
|
|
4732
|
-
const transport = mainline || pinned ? new (await (import("./mainline-
|
|
4787
|
+
const transport = mainline || pinned ? new (await (import("./mainline-BI-TebeH.js"))).RelaysAndDht(mainline, pinned ? { relays: pinned } : {}, !!pinned) : null;
|
|
4733
4788
|
const apps = servedApps(paths.dir).length > 0;
|
|
4734
4789
|
const server = new EngineServer({
|
|
4735
4790
|
...transport ? { transport } : {},
|
|
@@ -5067,4 +5122,4 @@ function connection(ctx, socket, secret) {
|
|
|
5067
5122
|
//#endregion
|
|
5068
5123
|
export { BASELINE_NEWEST, MAX_LINE, MAX_UNREAD, keepServing, openHost, serve };
|
|
5069
5124
|
|
|
5070
|
-
//# sourceMappingURL=host-
|
|
5125
|
+
//# sourceMappingURL=host-bGuDUvo3.js.map
|