@ghostlytools/cli 1.13.0 → 1.13.1
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 +7 -6
- package/dist/assets/{api-CVtg7MpI.js → api-DF36rBJK.js} +2 -2
- package/dist/assets/{api-CjOaoG-v.js → api-Dnq86JAA.js} +135 -37
- package/dist/assets/api-Dnq86JAA.js.map +1 -0
- package/dist/assets/{apiKit-BAGvlQtm.js → apiKit-nLK4jeTq.js} +3 -3
- package/dist/assets/{apiKit-BAGvlQtm.js.map → apiKit-nLK4jeTq.js.map} +1 -1
- package/dist/assets/{appFetch-BwJd-kNq.js → appFetch-wqBWi3Ry.js} +2 -2
- package/dist/assets/{appFetch-BwJd-kNq.js.map → appFetch-wqBWi3Ry.js.map} +1 -1
- package/dist/assets/{apps-Cuk45sz5.js → apps-DBVhKpfe.js} +10 -10
- package/dist/assets/apps-DBVhKpfe.js.map +1 -0
- package/dist/assets/{apps-DjY095Af.js → apps-nLtyhC2f.js} +1 -1
- package/dist/assets/{backup-DekVCDWv.js → backup-Bczllmzf.js} +4 -4
- package/dist/assets/{backup-DekVCDWv.js.map → backup-Bczllmzf.js.map} +1 -1
- package/dist/assets/{backup-B56sQqoQ.js → backup-D6s0LQdg.js} +1 -1
- package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js.map +1 -1
- package/dist/assets/{bitcoind-B2bbVSzh.js → bitcoind-DML_-Xbv.js} +2 -2
- package/dist/assets/{bitcoind-B2bbVSzh.js.map → bitcoind-DML_-Xbv.js.map} +1 -1
- package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js.map +1 -1
- package/dist/assets/{buttons-BGxzOtrq.js → buttons-B3C3vdhH.js} +8 -8
- package/dist/assets/buttons-B3C3vdhH.js.map +1 -0
- package/dist/assets/buttons-DaY5FYlV.js +1 -0
- package/dist/assets/{client-DcQAfc3h.js → client-B7jRrSnb.js} +3 -3
- package/dist/assets/{client-DcQAfc3h.js.map → client-B7jRrSnb.js.map} +1 -1
- package/dist/assets/{domainProofs-BDNP1dIy.js → domainProofs-b3Y1Gj9g.js} +6 -2
- package/dist/assets/{domainProofs-BDNP1dIy.js.map → domainProofs-b3Y1Gj9g.js.map} +1 -1
- package/dist/assets/{errors-DDLFO4Gf.js → errors-JVJsO8Iu.js} +18 -2
- package/dist/assets/errors-JVJsO8Iu.js.map +1 -0
- package/dist/assets/{fixedHosts-C3hBliM9.js → fixedHosts-H3i6o9Iy.js} +2 -2
- package/dist/assets/{fixedHosts-C3hBliM9.js.map → fixedHosts-H3i6o9Iy.js.map} +1 -1
- package/dist/assets/{ghostly_iroh_web-DIj5xGmR.js → ghostly_iroh_web-9VOwZcJQ.js} +30 -35
- package/dist/assets/ghostly_iroh_web-9VOwZcJQ.js.map +1 -0
- package/dist/assets/ghostly_iroh_web_bg.wasm +0 -0
- package/dist/assets/{groupMeta-goASqzOt.js → groupMeta--fxSh792.js} +72 -4
- package/dist/assets/groupMeta--fxSh792.js.map +1 -0
- package/dist/assets/{host-C2WRKj3g.js → host-CGzVFfMz.js} +169 -36
- package/dist/assets/host-CGzVFfMz.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-bjNGacf5.js → hyperdhtRelay-B4_wdCtx.js} +2 -2
- package/dist/assets/{hyperdhtRelay-bjNGacf5.js.map → hyperdhtRelay-B4_wdCtx.js.map} +1 -1
- package/dist/assets/{hyperdhtRelay-DLUiwfnt.js → hyperdhtRelay-Ce-gWsRY.js} +2 -2
- package/dist/assets/{hyperdhtRelay-DLUiwfnt.js.map → hyperdhtRelay-Ce-gWsRY.js.map} +1 -1
- package/dist/assets/{irohWeb-NfthOL98.js → irohWeb-Dp1i8v6n.js} +12 -11
- package/dist/assets/irohWeb-Dp1i8v6n.js.map +1 -0
- package/dist/assets/{main-Dh7fePd8.js → main-C8J53SwH.js} +67 -62
- package/dist/assets/main-C8J53SwH.js.map +1 -0
- package/dist/assets/{ownDid-BErplN7N.js → ownDid-oa-T2vmZ.js} +8 -4
- package/dist/assets/ownDid-oa-T2vmZ.js.map +1 -0
- package/dist/assets/{ownStatus-ClrFjd7h.js → ownStatus-Bc08eNJY.js} +6 -6
- package/dist/assets/{ownStatus-ClrFjd7h.js.map → ownStatus-Bc08eNJY.js.map} +1 -1
- package/dist/assets/{pairedTransports-BKmvlKz1.js → pairedTransports-Dppn8lUN.js} +3 -3
- package/dist/assets/pairedTransports-Dppn8lUN.js.map +1 -0
- package/dist/assets/{profiles-B8xO8-oj.js → profiles-B2uy04ph.js} +3 -3
- package/dist/assets/{profiles-B8xO8-oj.js.map → profiles-B2uy04ph.js.map} +1 -1
- package/dist/assets/{registry-CU8PevhI.js → registry-DbTLLs3y.js} +9 -5
- package/dist/assets/registry-DbTLLs3y.js.map +1 -0
- package/dist/assets/{registry--Rg2YvOH.js → registry-bLIfG619.js} +1 -1
- package/dist/assets/{resolve-B1upovPM.js → resolve-DNX-eecG.js} +9 -4
- package/dist/assets/resolve-DNX-eecG.js.map +1 -0
- package/dist/assets/secretGuard-Bh11MPdI.js +1 -0
- package/dist/assets/{secretGuard-BrATm_gl.js → secretGuard-oz_3hBfW.js} +19 -2
- package/dist/assets/{secretGuard-BrATm_gl.js.map → secretGuard-oz_3hBfW.js.map} +1 -1
- package/dist/assets/{server-Dgxx_DaN.js → server-DWJ4RzJn.js} +536 -209
- package/dist/assets/server-DWJ4RzJn.js.map +1 -0
- package/dist/assets/{translate-BcbSWkuq.js → translate-CHj_PdLg.js} +13 -8
- package/dist/assets/translate-CHj_PdLg.js.map +1 -0
- package/dist/assets/{waitNotice-ylU3XwjO.js → waitNotice-Cvz5CiKR.js} +57 -3
- package/dist/assets/waitNotice-Cvz5CiKR.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/assets/api-CjOaoG-v.js.map +0 -1
- package/dist/assets/apps-Cuk45sz5.js.map +0 -1
- package/dist/assets/buttons-BGxzOtrq.js.map +0 -1
- package/dist/assets/buttons-CsN2WJOf.js +0 -1
- package/dist/assets/errors-DDLFO4Gf.js.map +0 -1
- package/dist/assets/ghostly_iroh_web-DIj5xGmR.js.map +0 -1
- package/dist/assets/groupMeta-goASqzOt.js.map +0 -1
- package/dist/assets/host-C2WRKj3g.js.map +0 -1
- package/dist/assets/irohWeb-NfthOL98.js.map +0 -1
- package/dist/assets/main-Dh7fePd8.js.map +0 -1
- package/dist/assets/ownDid-BErplN7N.js.map +0 -1
- package/dist/assets/pairedTransports-BKmvlKz1.js.map +0 -1
- package/dist/assets/registry-CU8PevhI.js.map +0 -1
- package/dist/assets/resolve-B1upovPM.js.map +0 -1
- package/dist/assets/secretGuard-Bm6nci0I.js +0 -1
- package/dist/assets/server-Dgxx_DaN.js.map +0 -1
- package/dist/assets/translate-BcbSWkuq.js.map +0 -1
- package/dist/assets/waitNotice-ylU3XwjO.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { p as fileStore } from "./idb-ewvbqyDI.js";
|
|
2
|
-
import { _ as groupPayTwins, d as servedApps, f as nodeLocalFetch, g as groupMessageJson, h as groupJson, l as paymentJson, m as chatMessageJson, p as chatJson, r as callApi, u as reportAppFrames, v as resumeHolds, y as flushCardUpdates } from "./api-
|
|
3
|
-
import { N as sinceSeq, s as findChat, u as findOwnNamedChat } from "./apiKit-
|
|
4
|
-
import { r as asCliError, t as CliError } from "./errors-
|
|
5
|
-
import { C as ownFolder, D as runtimePath, E as privateFolder, n as RESTORED_MARK, r as acquireLock, w as ownProfile, x as startingPath } from "./profiles-
|
|
6
|
-
import { _ as frameBytes, b as monotonic, d as proof, f as removeDaemonSecret, g as bytesToMs, h as PlaybackQueue, l as greeting, m as DEFAULT_RATE, u as newDaemonSecret, v as frameSamples, y as isCallRate } from "./client-
|
|
7
|
-
import {
|
|
8
|
-
import { d as parsePayLink, r as irohRelayProblem } from "./irohWeb-
|
|
2
|
+
import { _ as groupPayTwins, d as servedApps, f as nodeLocalFetch, g as groupMessageJson, h as groupJson, l as paymentJson, m as chatMessageJson, p as chatJson, r as callApi, u as reportAppFrames, v as resumeHolds, y as flushCardUpdates } from "./api-Dnq86JAA.js";
|
|
3
|
+
import { N as sinceSeq, s as findChat, u as findOwnNamedChat } from "./apiKit-nLK4jeTq.js";
|
|
4
|
+
import { o as shownValue, r as asCliError, t as CliError } from "./errors-JVJsO8Iu.js";
|
|
5
|
+
import { C as ownFolder, D as runtimePath, E as privateFolder, n as RESTORED_MARK, r as acquireLock, w as ownProfile, x as startingPath } from "./profiles-B2uy04ph.js";
|
|
6
|
+
import { _ as frameBytes, b as monotonic, d as proof, f as removeDaemonSecret, g as bytesToMs, h as PlaybackQueue, l as greeting, m as DEFAULT_RATE, u as newDaemonSecret, v as frameSamples, y as isCallRate } from "./client-B7jRrSnb.js";
|
|
7
|
+
import { Ci as DAEMON_WATCH_PEER_IDLE_MS, Gi as callSignalHeardAt, Hi as answersOffer, Ji as parseCallSignal, Qt as checkPushEndpoint, St as STATUS_IDLE_AFTER_MS, Ui as buildSdpFromSignal, Vi as RTC_CONFIG, Wi as callRtcConfig, Yi as signalHasVideo, _n as ACTIVE_DHT_POLL_MS, qi as extractParamsFromSdp, zi as CALL_SIGNAL_MAX_AGE_MS } from "./groupMeta--fxSh792.js";
|
|
8
|
+
import { d as parsePayLink, r as irohRelayProblem } from "./irohWeb-Dp1i8v6n.js";
|
|
9
9
|
import { i as fromBase64Url } from "./bytes-C1DNGY18.js";
|
|
10
10
|
import { u as setLinkTraceSink } from "./relay-CHWg5hpZ.js";
|
|
11
11
|
import { b as setPublicKeyFastPath } from "./pkarr-BQo4PcCg.js";
|
|
12
|
-
import { p as nativePublicKey } from "./apps-
|
|
12
|
+
import { p as nativePublicKey } from "./apps-DBVhKpfe.js";
|
|
13
13
|
import { n as fedimintSdkOn } from "./fedimintSdk-D-6H9Pe7.js";
|
|
14
|
-
import { s as isPublicAddress } from "./domainProofs-
|
|
14
|
+
import { s as isPublicAddress } from "./domainProofs-b3Y1Gj9g.js";
|
|
15
15
|
import { createRequire } from "node:module";
|
|
16
16
|
import { appendFileSync, chmodSync, closeSync, existsSync, fstatSync, fsync, fsyncSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, truncateSync, writeFileSync, writeSync } from "node:fs";
|
|
17
17
|
import { open, readFile } from "node:fs/promises";
|
|
@@ -658,7 +658,7 @@ function envSwitch(name, fallback, env = process.env) {
|
|
|
658
658
|
if (value === void 0 || value.trim() === "") return fallback;
|
|
659
659
|
if (OFF.test(value.trim())) return false;
|
|
660
660
|
if (ON.test(value.trim())) return true;
|
|
661
|
-
throw new CliError("usage", `${name} takes 0 or 1 (or false/true, off/on, no/yes), not ${
|
|
661
|
+
throw new CliError("usage", `${name} takes 0 or 1 (or false/true, off/on, no/yes), not ${shownValue(value)}`);
|
|
662
662
|
}
|
|
663
663
|
// src/runtime/rtcThreads.ts
|
|
664
664
|
/**
|
|
@@ -3694,7 +3694,8 @@ var GroupAutoJoin = class {
|
|
|
3694
3694
|
* every change of the engine's state. One whose accept fails (the contact is not connected yet) is tried again on a
|
|
3695
3695
|
* later change. Another contact who knows the group's id may have invited first: the engine then keeps the granted
|
|
3696
3696
|
* one beside it (`others`), and it is the one taken (`switchGroup`, which tells the other contact no), as long as the
|
|
3697
|
-
* group held is only an invitation not answered yet. One beside a group joined or accepted
|
|
3697
|
+
* group held is only an invitation not answered yet. One beside a group joined or accepted, or beside an invitation
|
|
3698
|
+
* that keeps a group this device was in (`kept`: switching would delete its history), waits for the person.
|
|
3698
3699
|
*/
|
|
3699
3700
|
check(state) {
|
|
3700
3701
|
if (!this.host.joins || !this.grants.length) return;
|
|
@@ -3719,7 +3720,7 @@ var GroupAutoJoin = class {
|
|
|
3719
3720
|
const other = group.others?.find((o) => "linkId" in o && granted(o.linkId));
|
|
3720
3721
|
if (!other || !("linkId" in other)) continue;
|
|
3721
3722
|
const held = group.invitation;
|
|
3722
|
-
if (group.status === void 0 && held && !held.accepted && !held.viaLink) {
|
|
3723
|
+
if (group.status === void 0 && held && !held.accepted && !held.viaLink && !held.kept) {
|
|
3723
3724
|
this.accept(group.id, other.linkId, true);
|
|
3724
3725
|
continue;
|
|
3725
3726
|
}
|
|
@@ -4016,6 +4017,46 @@ async function nodePushSend(push, lookup = publicOnlyLookup) {
|
|
|
4016
4017
|
req.end(push.body);
|
|
4017
4018
|
});
|
|
4018
4019
|
}
|
|
4020
|
+
// src/runtime/groupCallFetch.ts
|
|
4021
|
+
/**
|
|
4022
|
+
* How the CLI asks a group's call node (WISP 602 § The token request, § Moderation) at the origin the group's admin
|
|
4023
|
+
* named: an HTTPS POST only at a public address, or at a name whose every address is public, checked when the
|
|
4024
|
+
* connection is made, as an identity's proof is read (./publicFetch.ts). No redirect is followed (one is answered as it
|
|
4025
|
+
* came: the engine takes only a 2xx), no proxy, no cookie. The engine bounds the time and the size of the reply.
|
|
4026
|
+
*/
|
|
4027
|
+
function nodeGroupCallFetch(lookup = publicOnlyLookup) {
|
|
4028
|
+
return async (input, init) => {
|
|
4029
|
+
const url = new URL(typeof input === "string" ? input : input instanceof URL ? input.href : input.url);
|
|
4030
|
+
if (url.protocol !== "https:") throw new TypeError("Only HTTPS is sent");
|
|
4031
|
+
if ((init?.method ?? "GET").toUpperCase() !== "POST") throw new TypeError("Only POST is sent");
|
|
4032
|
+
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
4033
|
+
if (isIP(host) && !isPublicIp(host)) throw new TypeError(`${host} is not a public address`);
|
|
4034
|
+
const body = typeof init?.body === "string" ? init.body : "";
|
|
4035
|
+
const headers = {
|
|
4036
|
+
...Object.fromEntries(new Headers(init?.headers)),
|
|
4037
|
+
"content-length": String(Buffer.byteLength(body))
|
|
4038
|
+
};
|
|
4039
|
+
return new Promise((resolve, reject) => {
|
|
4040
|
+
const req = request(url, {
|
|
4041
|
+
method: "POST",
|
|
4042
|
+
headers,
|
|
4043
|
+
lookup,
|
|
4044
|
+
agent: false,
|
|
4045
|
+
signal: init?.signal ?? void 0
|
|
4046
|
+
}, (res) => {
|
|
4047
|
+
const out = new Headers();
|
|
4048
|
+
for (const [name, value] of Object.entries(res.headers)) if (typeof value === "string") out.set(name, value);
|
|
4049
|
+
const status = res.statusCode ?? 0;
|
|
4050
|
+
resolve(new Response(status === 204 || status === 304 ? null : Readable.toWeb(res), {
|
|
4051
|
+
status,
|
|
4052
|
+
headers: out
|
|
4053
|
+
}));
|
|
4054
|
+
});
|
|
4055
|
+
req.on("error", reject);
|
|
4056
|
+
req.end(body);
|
|
4057
|
+
});
|
|
4058
|
+
};
|
|
4059
|
+
}
|
|
4019
4060
|
// src/runtime/holdFetch.ts
|
|
4020
4061
|
/**
|
|
4021
4062
|
* How the CLI reads a held item or manifest (WISP 404): a GET to the address the contact chose, only
|
|
@@ -4095,6 +4136,23 @@ function nodePublicFetch(lookup = publicOnlyLookup) {
|
|
|
4095
4136
|
}
|
|
4096
4137
|
};
|
|
4097
4138
|
}
|
|
4139
|
+
/**
|
|
4140
|
+
* How the CLI asks a Lightning address or LNURL service (WISP 205 § Transport), its redirects and its callback: as an
|
|
4141
|
+
* identity's address, at a name whose every address is public when it connects. The engine follows each redirect
|
|
4142
|
+
* itself (`redirect: "manual"`) and checks names only. A service the person named on this machine itself (a test
|
|
4143
|
+
* server, plain HTTP allowed) is asked as named.
|
|
4144
|
+
*/
|
|
4145
|
+
function nodeLnurlFetch(lookup = publicOnlyLookup, local = (...request) => globalThis.fetch(...request)) {
|
|
4146
|
+
const publicFetch = nodePublicFetch(lookup);
|
|
4147
|
+
return (input, init) => {
|
|
4148
|
+
const url = new URL(typeof input === "string" ? input : input instanceof URL ? input.href : input.url);
|
|
4149
|
+
return [
|
|
4150
|
+
"localhost",
|
|
4151
|
+
"127.0.0.1",
|
|
4152
|
+
"[::1]"
|
|
4153
|
+
].includes(url.hostname) ? local(input, init) : publicFetch(input, init);
|
|
4154
|
+
};
|
|
4155
|
+
}
|
|
4098
4156
|
// src/runtime/irohRelay.ts
|
|
4099
4157
|
/**
|
|
4100
4158
|
* Whether the CLI's Iroh may dial a contact through the relay its descriptor names (irohWeb.ts `publicRelay`): at a
|
|
@@ -4829,6 +4887,8 @@ var SEQ = "__ghostly_entry__";
|
|
|
4829
4887
|
var CLOSE_WAIT_MS = 5e3;
|
|
4830
4888
|
/** Records an export reads and serializes in one turn of the event loop, then writes: a few milliseconds' worth. */
|
|
4831
4889
|
var EXPORT_PAGE = 256;
|
|
4890
|
+
/** How long a fold's snapshot serializes records before it writes them and lets the daemon's other work run. */
|
|
4891
|
+
var PAGE_MS = 5;
|
|
4832
4892
|
/** How long a relaxed transaction's entry may wait for a sync when no other transaction brings one. */
|
|
4833
4893
|
var RELAXED_SYNC_MS = 1e3;
|
|
4834
4894
|
/**
|
|
@@ -5073,7 +5133,8 @@ async function openPersistentIndexedDb(dir, options = {}) {
|
|
|
5073
5133
|
* text the engine had told the contact it held.
|
|
5074
5134
|
*/
|
|
5075
5135
|
function append(ops, lazy, entry, owner, complete) {
|
|
5076
|
-
|
|
5136
|
+
const deleting = ops.some(deletes);
|
|
5137
|
+
holdsDelete ||= deleting;
|
|
5077
5138
|
if (trees) ops = [{
|
|
5078
5139
|
db: SEQ,
|
|
5079
5140
|
store: "",
|
|
@@ -5099,7 +5160,10 @@ async function openPersistentIndexedDb(dir, options = {}) {
|
|
|
5099
5160
|
if (writeEntry(serialize(await Promise.all(ops.map(async (op) => op.kind === "put" ? {
|
|
5100
5161
|
...op,
|
|
5101
5162
|
value: await blobsToDisk(op.value)
|
|
5102
|
-
} : op))), lazy ? "lazy" : "now"))
|
|
5163
|
+
} : op))), lazy ? "lazy" : "now")) {
|
|
5164
|
+
holdsDelete ||= deleting;
|
|
5165
|
+
written(entry);
|
|
5166
|
+
}
|
|
5103
5167
|
} catch (error) {
|
|
5104
5168
|
failed(error);
|
|
5105
5169
|
await writeSnapshot().catch(failed);
|
|
@@ -5315,7 +5379,10 @@ async function openPersistentIndexedDb(dir, options = {}) {
|
|
|
5315
5379
|
}))
|
|
5316
5380
|
};
|
|
5317
5381
|
}
|
|
5318
|
-
/**
|
|
5382
|
+
/**
|
|
5383
|
+
* What is held, as a snapshot of format 3: the stores kept on disk say only that they are. `upTo`: the last entry it
|
|
5384
|
+
* holds, the transactions whose layers go to the trees with it.
|
|
5385
|
+
*/
|
|
5319
5386
|
async function capture(journalName) {
|
|
5320
5387
|
const snapshot = {
|
|
5321
5388
|
format: 1,
|
|
@@ -5340,9 +5407,8 @@ async function openPersistentIndexedDb(dir, options = {}) {
|
|
|
5340
5407
|
}
|
|
5341
5408
|
const saved = {
|
|
5342
5409
|
...storeMeta(store),
|
|
5343
|
-
records: []
|
|
5410
|
+
records: treeRecords(store.records).map(({ key, value }) => [key, value])
|
|
5344
5411
|
};
|
|
5345
|
-
for (const record of store.records.values()) saved.records.push([record.key, record.value]);
|
|
5346
5412
|
stores.push(saved);
|
|
5347
5413
|
held.push(saved);
|
|
5348
5414
|
}
|
|
@@ -5352,8 +5418,12 @@ async function openPersistentIndexedDb(dir, options = {}) {
|
|
|
5352
5418
|
stores
|
|
5353
5419
|
});
|
|
5354
5420
|
}
|
|
5355
|
-
|
|
5356
|
-
|
|
5421
|
+
const upTo = seq;
|
|
5422
|
+
for (const store of held) for (const record of store.records) if (hasBlob(record[1])) record[1] = await blobsToDisk(record[1]);
|
|
5423
|
+
return {
|
|
5424
|
+
snapshot,
|
|
5425
|
+
upTo
|
|
5426
|
+
};
|
|
5357
5427
|
}
|
|
5358
5428
|
/**
|
|
5359
5429
|
* The whole store as a snapshot of format 1 (every value inline, `rows.db` read), written to `file` as it is read: a
|
|
@@ -5434,29 +5504,34 @@ async function openPersistentIndexedDb(dir, options = {}) {
|
|
|
5434
5504
|
}
|
|
5435
5505
|
async function snapshotToDisk(scrub = false) {
|
|
5436
5506
|
await synced();
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
trees.apply(seq);
|
|
5441
|
-
if (scrub) trees.scrub();
|
|
5442
|
-
trees.sync();
|
|
5507
|
+
if (relaxed) {
|
|
5508
|
+
clearTimeout(relaxed);
|
|
5509
|
+
relaxed = null;
|
|
5443
5510
|
}
|
|
5511
|
+
const name = randomBytes(8).toString("hex");
|
|
5512
|
+
const { snapshot, upTo } = await capture(name);
|
|
5513
|
+
const live = trees ? liveTrees() : null;
|
|
5514
|
+
unsaved = false;
|
|
5444
5515
|
const temporary = snapshotPath + ".tmp";
|
|
5445
|
-
const
|
|
5516
|
+
const file = await open(temporary, "w", 384);
|
|
5446
5517
|
try {
|
|
5447
|
-
|
|
5448
|
-
|
|
5518
|
+
await writeSnapshotTo(file, snapshot);
|
|
5519
|
+
await file.sync();
|
|
5449
5520
|
} finally {
|
|
5450
|
-
|
|
5521
|
+
await file.close();
|
|
5522
|
+
}
|
|
5523
|
+
if (trees) {
|
|
5524
|
+
trees.apply(upTo);
|
|
5525
|
+
if (scrub) trees.scrub();
|
|
5526
|
+
trees.sync();
|
|
5451
5527
|
}
|
|
5452
5528
|
renameSync(temporary, snapshotPath);
|
|
5453
5529
|
try {
|
|
5454
|
-
trees
|
|
5530
|
+
if (live) trees.sweep(/* @__PURE__ */ new Set([...live, ...liveTrees()]));
|
|
5455
5531
|
} catch (error) {
|
|
5456
5532
|
process.stderr.write(`ghostly: storage: old trees not removed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
5457
5533
|
}
|
|
5458
5534
|
snapshotName = name;
|
|
5459
|
-
unsaved = false;
|
|
5460
5535
|
if (relaxed) {
|
|
5461
5536
|
clearTimeout(relaxed);
|
|
5462
5537
|
relaxed = null;
|
|
@@ -5548,6 +5623,44 @@ function writeAll(fd, bytes) {
|
|
|
5548
5623
|
for (let at = 0; at < bytes.length;) at += writeSync(fd, bytes, at);
|
|
5549
5624
|
}
|
|
5550
5625
|
/**
|
|
5626
|
+
* A snapshot to `file`, its records `EXPORT_PAGE` at a time (or fewer, large ones: `PAGE_MS` of the thread) with a write
|
|
5627
|
+
* between: what `serialize(snapshot)` would write.
|
|
5628
|
+
*/
|
|
5629
|
+
async function writeSnapshotTo(file, snapshot) {
|
|
5630
|
+
const out = new SnapshotWriter(file);
|
|
5631
|
+
const { databases, ...head } = snapshot;
|
|
5632
|
+
out.begin("o");
|
|
5633
|
+
for (const [key, value] of Object.entries(head)) out.value(key, value);
|
|
5634
|
+
out.key("databases");
|
|
5635
|
+
out.begin("A", databases.length);
|
|
5636
|
+
for (const { stores, ...db } of databases) {
|
|
5637
|
+
out.begin("o");
|
|
5638
|
+
for (const [key, value] of Object.entries(db)) out.value(key, value);
|
|
5639
|
+
out.key("stores");
|
|
5640
|
+
out.begin("A", stores.length);
|
|
5641
|
+
for (const { records, ...meta } of stores) {
|
|
5642
|
+
out.begin("o");
|
|
5643
|
+
for (const [key, value] of Object.entries(meta)) out.value(key, value);
|
|
5644
|
+
out.key("records");
|
|
5645
|
+
out.begin("A", records.length);
|
|
5646
|
+
let due = performance.now() + PAGE_MS;
|
|
5647
|
+
for (let at = 0; at < records.length; at++) {
|
|
5648
|
+
out.item(records[at]);
|
|
5649
|
+
if ((at + 1) % EXPORT_PAGE !== 0 && performance.now() < due) continue;
|
|
5650
|
+
await out.flush();
|
|
5651
|
+
due = performance.now() + PAGE_MS;
|
|
5652
|
+
}
|
|
5653
|
+
out.end("A", records.length);
|
|
5654
|
+
out.end("o", Object.keys(meta).length + 1);
|
|
5655
|
+
}
|
|
5656
|
+
out.end("A", stores.length);
|
|
5657
|
+
out.end("o", Object.keys(db).length + 1);
|
|
5658
|
+
}
|
|
5659
|
+
out.end("A", databases.length);
|
|
5660
|
+
out.end("o", Object.keys(head).length + 1);
|
|
5661
|
+
await out.flush();
|
|
5662
|
+
}
|
|
5663
|
+
/**
|
|
5551
5664
|
* A value v8 would serialize whole, written in pieces: the objects and arrays around the records begun and ended here
|
|
5552
5665
|
* by hand, as v8 itself writes them, and the records serialized a page at a time, each page's bytes to `file`. A reader
|
|
5553
5666
|
* gets what `deserialize` of `serialize(value)` gives (the bytes differ at most by v8's alignment padding before a
|
|
@@ -6071,6 +6184,24 @@ function absent(keyPath, value) {
|
|
|
6071
6184
|
return false;
|
|
6072
6185
|
}
|
|
6073
6186
|
/**
|
|
6187
|
+
* A store's records in key order, read off fake-indexeddb's red-black tree node by node: its own iterator nests a
|
|
6188
|
+
* generator per level and checks the range at each node, 360 ms of the daemon's thread for a seen set of 300,000 notes.
|
|
6189
|
+
*/
|
|
6190
|
+
function treeRecords(store) {
|
|
6191
|
+
const records = [], above = [];
|
|
6192
|
+
for (let node = store.records._root; node || above.length;) {
|
|
6193
|
+
if (node) {
|
|
6194
|
+
above.push(node);
|
|
6195
|
+
node = node.left;
|
|
6196
|
+
continue;
|
|
6197
|
+
}
|
|
6198
|
+
node = above.pop();
|
|
6199
|
+
if (!node.deleted) records.push(node.record);
|
|
6200
|
+
node = node.right;
|
|
6201
|
+
}
|
|
6202
|
+
return records;
|
|
6203
|
+
}
|
|
6204
|
+
/**
|
|
6074
6205
|
* fake-indexeddb's red-black tree, built balanced from sorted records: every level full but the last, whose nodes
|
|
6075
6206
|
* are red, so each path holds the same number of black nodes and later inserts rebalance as usual.
|
|
6076
6207
|
*/
|
|
@@ -6355,7 +6486,7 @@ function bootstrapNodes(name, env) {
|
|
|
6355
6486
|
const port = /^[^\s:;/@[\]]+:(\d{1,5})$/.exec(node)?.[1];
|
|
6356
6487
|
return !port || Number(port) < 1 || Number(port) > 65535;
|
|
6357
6488
|
});
|
|
6358
|
-
if (bad !== void 0) throw new CliError("usage", `${name} takes host:port nodes, comma-separated, not ${
|
|
6489
|
+
if (bad !== void 0) throw new CliError("usage", `${name} takes host:port nodes, comma-separated, not ${shownValue(bad)}`);
|
|
6359
6490
|
return nodes;
|
|
6360
6491
|
}
|
|
6361
6492
|
/**
|
|
@@ -6367,7 +6498,7 @@ function pkarrRelays(env = process.env) {
|
|
|
6367
6498
|
const relays = (env.GHOSTLY_PKARR_RELAYS ?? "").split(",").map((url) => url.trim()).filter(Boolean);
|
|
6368
6499
|
if (!relays.length) return null;
|
|
6369
6500
|
const bad = relays.find((url) => !/^https?:\/\/[^/\s]/i.test(url) || /[\s;]/.test(url) || !URL.canParse(url));
|
|
6370
|
-
if (bad) throw new CliError("usage", `GHOSTLY_PKARR_RELAYS takes http:// or https:// URLs, comma-separated, not ${
|
|
6501
|
+
if (bad) throw new CliError("usage", `GHOSTLY_PKARR_RELAYS takes http:// or https:// URLs, comma-separated, not ${shownValue(bad)}`);
|
|
6371
6502
|
return relays;
|
|
6372
6503
|
}
|
|
6373
6504
|
/**
|
|
@@ -6581,11 +6712,11 @@ async function startRuntime(paths, options = {}) {
|
|
|
6581
6712
|
if (testMints) (await import("./mints-BcBODVVW.js")).declareTestMints(testMints.split(","));
|
|
6582
6713
|
await installEventSource();
|
|
6583
6714
|
await preloadWalletModules();
|
|
6584
|
-
(await import("./ghostly_iroh_web-
|
|
6715
|
+
(await import("./ghostly_iroh_web-9VOwZcJQ.js")).initSync({ module: irohWasmBytes() });
|
|
6585
6716
|
const [{ registerFileBytes }, { NodeFileBytes }] = await Promise.all([import("./fileBytes-CCKbwqG_.js"), import("./fileBytes-tj6-VZcB.js")]);
|
|
6586
6717
|
registerFileBytes("native", async () => new NodeFileBytes(paths.files), true);
|
|
6587
6718
|
if (await (await import("./blobFiles-DDs34n0r.js")).moveBlobFiles()) await store.compact();
|
|
6588
|
-
const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-
|
|
6719
|
+
const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-DWJ4RzJn.js"), import("./endpoint-Cvu-taMs.js")]);
|
|
6589
6720
|
const mainline = dht.off ? null : new (await (import("./mainline-DY95WbuK.js"))).Mainline({
|
|
6590
6721
|
bootstrap: dht.bootstrap,
|
|
6591
6722
|
host: dht.host
|
|
@@ -6614,6 +6745,8 @@ async function startRuntime(paths, options = {}) {
|
|
|
6614
6745
|
pushSend: (request) => nodePushSend(request),
|
|
6615
6746
|
holdFetch: nodeHoldFetch(),
|
|
6616
6747
|
identityFetch: nodePublicFetch(),
|
|
6748
|
+
groupCallFetch: nodeGroupCallFetch(),
|
|
6749
|
+
lnurlFetch: nodeLnurlFetch(),
|
|
6617
6750
|
webrtcIgnoresRelayOnly: true,
|
|
6618
6751
|
callsSupport: callsUnavailable === null,
|
|
6619
6752
|
...callsUnavailable ? { callsUnavailable } : {},
|
|
@@ -7054,4 +7187,4 @@ function connection(ctx, socket, secret, answering) {
|
|
|
7054
7187
|
}
|
|
7055
7188
|
export { BASELINE_NEWEST, MAX_UNREAD, STOP_ANSWERS_MS, keepServing, openHost, serve };
|
|
7056
7189
|
|
|
7057
|
-
//# sourceMappingURL=host-
|
|
7190
|
+
//# sourceMappingURL=host-CGzVFfMz.js.map
|