@pkcprotocol/pkc-js 0.0.138 → 0.0.140
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 +1 -1
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/helia/dial-address-sorter.d.ts +2 -0
- package/dist/browser/helia/dial-address-sorter.js +52 -0
- package/dist/browser/helia/dial-address-sorter.js.map +1 -0
- package/dist/browser/helia/dial-transport-filter.d.ts +1 -1
- package/dist/browser/helia/dial-transport-filter.js +12 -11
- package/dist/browser/helia/dial-transport-filter.js.map +1 -1
- package/dist/browser/helia/helia-for-pkc.js +11 -3
- package/dist/browser/helia/helia-for-pkc.js.map +1 -1
- package/dist/browser/helia/util.d.ts +3 -0
- package/dist/browser/helia/util.js +169 -55
- package/dist/browser/helia/util.js.map +1 -1
- package/dist/browser/runtime/browser/libp2p-extra-transports.js +7 -1
- package/dist/browser/runtime/browser/libp2p-extra-transports.js.map +1 -1
- package/dist/browser/runtime/browser/webtransport-close-shim.d.ts +24 -0
- package/dist/browser/runtime/browser/webtransport-close-shim.js +65 -0
- package/dist/browser/runtime/browser/webtransport-close-shim.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.d.ts +1 -1
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js +5 -4
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
- package/dist/browser/runtime/node/community/page-generator.js +38 -15
- package/dist/browser/runtime/node/community/page-generator.js.map +1 -1
- package/dist/browser/runtime/node/webtransport-close-shim.d.ts +4 -0
- package/dist/browser/runtime/node/webtransport-close-shim.js +7 -0
- package/dist/browser/runtime/node/webtransport-close-shim.js.map +1 -0
- package/dist/bundled/bundle-manifest.json +39 -35
- package/dist/bundled/challenges.js +1 -1
- package/dist/bundled/chunks/{helia-for-pkc-DDElBMjg.js → helia-for-pkc-D8Yy6QjO.js} +67 -38
- package/dist/bundled/chunks/{local-community-CwWE5aZI.js → local-community-3TpfDDKX.js} +1 -1
- package/dist/bundled/chunks/{local-community-WiVmJqKT.js → local-community-BIYHcGS5.js} +59 -44
- package/dist/bundled/chunks/{node-IAC_ZNSw.js → node-D0SiFYRw.js} +5 -5
- package/dist/bundled/chunks/{page-sort-scoring-3zupKJrA.js → page-sort-scoring-I74ngMaI.js} +1 -1
- package/dist/bundled/chunks/{rpc-local-community-B-qRj5uG.js → rpc-local-community-BHMWTLg2.js} +2 -2
- package/dist/bundled/chunks/{util-Nmcf8S1j.js → util-DkGqBo7o.js} +1 -1
- package/dist/bundled/chunks/{util-PmT6BP1t.js → util-Hi455mZb.js} +102 -36
- package/dist/bundled/chunks/{validate-package-factories-DN-pv9-T.js → validate-package-factories-BjxAINy2.js} +2 -2
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/page-sorts.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/helia/dial-address-sorter.d.ts +2 -0
- package/dist/node/helia/dial-address-sorter.js +52 -0
- package/dist/node/helia/dial-address-sorter.js.map +1 -0
- package/dist/node/helia/dial-transport-filter.d.ts +1 -1
- package/dist/node/helia/dial-transport-filter.js +12 -11
- package/dist/node/helia/dial-transport-filter.js.map +1 -1
- package/dist/node/helia/helia-for-pkc.js +11 -3
- package/dist/node/helia/helia-for-pkc.js.map +1 -1
- package/dist/node/helia/util.d.ts +3 -0
- package/dist/node/helia/util.js +169 -55
- package/dist/node/helia/util.js.map +1 -1
- package/dist/node/runtime/browser/libp2p-extra-transports.js +7 -1
- package/dist/node/runtime/browser/libp2p-extra-transports.js.map +1 -1
- package/dist/node/runtime/browser/webtransport-close-shim.d.ts +24 -0
- package/dist/node/runtime/browser/webtransport-close-shim.js +65 -0
- package/dist/node/runtime/browser/webtransport-close-shim.js.map +1 -0
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.d.ts +1 -1
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js +5 -4
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
- package/dist/node/runtime/node/community/page-generator.js +38 -15
- package/dist/node/runtime/node/community/page-generator.js.map +1 -1
- package/dist/node/runtime/node/webtransport-close-shim.d.ts +4 -0
- package/dist/node/runtime/node/webtransport-close-shim.js +7 -0
- package/dist/node/runtime/node/webtransport-close-shim.js.map +1 -0
- package/package.json +3 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { C as hideClassPrivateProps, Lr as PKCError, T as ipnsNameToIpnsOverPubsubTopic, n as binaryKeyToPubsubTopic, zr as logger_default } from "./util-
|
|
3
|
-
import { a as directFetchIpnsRecordFromProviders, c as readFreshCachedIpnsRecordFromPubsubLocalStore, i as connectToPubsubPeers, l as selectBitswapSessionSeedPeers, n as REACHABILITY_DOCS_URL, o as fetchBlockWithStalledSessionFailover, r as cacheIpnsRecordInPubsubLocalStore, s as getHeliaDebugContext, u as summarizeProviderReachability } from "./util-
|
|
2
|
+
import { C as hideClassPrivateProps, Lr as PKCError, T as ipnsNameToIpnsOverPubsubTopic, n as binaryKeyToPubsubTopic, zr as logger_default } from "./util-DkGqBo7o.js";
|
|
3
|
+
import { a as directFetchIpnsRecordFromProviders, c as readFreshCachedIpnsRecordFromPubsubLocalStore, i as connectToPubsubPeers, l as selectBitswapSessionSeedPeers, n as REACHABILITY_DOCS_URL, o as fetchBlockWithStalledSessionFailover, r as cacheIpnsRecordInPubsubLocalStore, s as getHeliaDebugContext, u as summarizeProviderReachability } from "./util-Hi455mZb.js";
|
|
4
4
|
import { t as map } from "./src-Cpx2Sts8.js";
|
|
5
5
|
import { t as parallelBatch } from "./src-DKntVmyX.js";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import fsp, { rename, writeFile } from "node:fs/promises";
|
|
8
|
-
import
|
|
9
|
-
import path
|
|
8
|
+
import Path, { basename, dirname, join } from "node:path";
|
|
9
|
+
import path from "path";
|
|
10
10
|
import { CID } from "multiformats/cid";
|
|
11
11
|
import { peerIdFromString } from "@libp2p/peer-id";
|
|
12
12
|
import * as Digest from "multiformats/hashes/digest";
|
|
@@ -16,6 +16,7 @@ import { ipnsSelector } from "ipns/selector";
|
|
|
16
16
|
import { ipnsValidator } from "ipns/validator";
|
|
17
17
|
import { multihashToIPNSRoutingKey, unmarshalIPNSRecord } from "ipns";
|
|
18
18
|
import { equals } from "uint8arrays/equals";
|
|
19
|
+
import { circuitRelayAddressesLast, loopbackAddressLast, publicAddressesFirst, reliableTransportsFirst } from "@libp2p/utils";
|
|
19
20
|
import { createHeliaLight } from "helia";
|
|
20
21
|
import { libp2pDefaults, withLibp2p } from "@helia/libp2p";
|
|
21
22
|
import { withBitswap } from "@helia/bitswap";
|
|
@@ -151,7 +152,7 @@ var require_path = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
151
152
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
152
153
|
exports.convertPosixPathToPattern = exports.convertWindowsPathToPattern = exports.convertPathToPattern = exports.escapePosixPath = exports.escapeWindowsPath = exports.escape = exports.removeLeadingDotSegment = exports.makeAbsolute = exports.unixify = void 0;
|
|
153
154
|
const os$1 = __require("os");
|
|
154
|
-
const path$
|
|
155
|
+
const path$9 = __require("path");
|
|
155
156
|
const IS_WINDOWS_PLATFORM = os$1.platform() === "win32";
|
|
156
157
|
const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
|
|
157
158
|
/**
|
|
@@ -180,7 +181,7 @@ var require_path = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
180
181
|
}
|
|
181
182
|
exports.unixify = unixify;
|
|
182
183
|
function makeAbsolute(cwd, filepath) {
|
|
183
|
-
return path$
|
|
184
|
+
return path$9.resolve(cwd, filepath);
|
|
184
185
|
}
|
|
185
186
|
exports.makeAbsolute = makeAbsolute;
|
|
186
187
|
function removeLeadingDotSegment(entry) {
|
|
@@ -1432,7 +1433,7 @@ var require_braces = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1432
1433
|
//#endregion
|
|
1433
1434
|
//#region node_modules/picomatch/lib/constants.js
|
|
1434
1435
|
var require_constants$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1435
|
-
const path$
|
|
1436
|
+
const path$8 = __require("path");
|
|
1436
1437
|
const WIN_SLASH = "\\\\/";
|
|
1437
1438
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
1438
1439
|
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
@@ -1557,7 +1558,7 @@ var require_constants$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1557
1558
|
CHAR_UNDERSCORE: 95,
|
|
1558
1559
|
CHAR_VERTICAL_LINE: 124,
|
|
1559
1560
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
1560
|
-
SEP: path$
|
|
1561
|
+
SEP: path$8.sep,
|
|
1561
1562
|
/**
|
|
1562
1563
|
* Create EXTGLOB_CHARS
|
|
1563
1564
|
*/
|
|
@@ -1601,7 +1602,7 @@ var require_constants$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1601
1602
|
//#endregion
|
|
1602
1603
|
//#region node_modules/picomatch/lib/utils.js
|
|
1603
1604
|
var require_utils$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1604
|
-
const path$
|
|
1605
|
+
const path$7 = __require("path");
|
|
1605
1606
|
const win32 = process.platform === "win32";
|
|
1606
1607
|
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants$1();
|
|
1607
1608
|
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
@@ -1621,7 +1622,7 @@ var require_utils$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
1621
1622
|
};
|
|
1622
1623
|
exports.isWindows = (options) => {
|
|
1623
1624
|
if (options && typeof options.windows === "boolean") return options.windows;
|
|
1624
|
-
return win32 === true || path$
|
|
1625
|
+
return win32 === true || path$7.sep === "\\";
|
|
1625
1626
|
};
|
|
1626
1627
|
exports.escapeLast = (input, char, lastIdx) => {
|
|
1627
1628
|
const idx = input.lastIndexOf(char, lastIdx);
|
|
@@ -2991,7 +2992,7 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2991
2992
|
//#endregion
|
|
2992
2993
|
//#region node_modules/picomatch/lib/picomatch.js
|
|
2993
2994
|
var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2994
|
-
const path$
|
|
2995
|
+
const path$6 = __require("path");
|
|
2995
2996
|
const scan = require_scan();
|
|
2996
2997
|
const parse = require_parse();
|
|
2997
2998
|
const utils = require_utils$2();
|
|
@@ -3130,7 +3131,7 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3130
3131
|
* @api public
|
|
3131
3132
|
*/
|
|
3132
3133
|
picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
|
|
3133
|
-
return (glob instanceof RegExp ? glob : picomatch.makeRe(glob, options)).test(path$
|
|
3134
|
+
return (glob instanceof RegExp ? glob : picomatch.makeRe(glob, options)).test(path$6.basename(input));
|
|
3134
3135
|
};
|
|
3135
3136
|
/**
|
|
3136
3137
|
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
@@ -3685,7 +3686,7 @@ var require_micromatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3685
3686
|
var require_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3686
3687
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3687
3688
|
exports.isAbsolute = exports.partitionAbsoluteAndRelative = exports.removeDuplicateSlashes = exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.isPatternRelatedToParentDirectory = exports.getPatternsOutsideCurrentDirectory = exports.getPatternsInsideCurrentDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = void 0;
|
|
3688
|
-
const path$
|
|
3689
|
+
const path$5 = __require("path");
|
|
3689
3690
|
const globParent = require_glob_parent();
|
|
3690
3691
|
const micromatch = require_micromatch();
|
|
3691
3692
|
const GLOBSTAR = "**";
|
|
@@ -3793,7 +3794,7 @@ var require_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3793
3794
|
}
|
|
3794
3795
|
exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
|
|
3795
3796
|
function isAffectDepthOfReadingPattern(pattern) {
|
|
3796
|
-
const basename = path$
|
|
3797
|
+
const basename = path$5.basename(pattern);
|
|
3797
3798
|
return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
|
|
3798
3799
|
}
|
|
3799
3800
|
exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
|
|
@@ -3867,7 +3868,7 @@ var require_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3867
3868
|
}
|
|
3868
3869
|
exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
|
|
3869
3870
|
function isAbsolute(pattern) {
|
|
3870
|
-
return path$
|
|
3871
|
+
return path$5.isAbsolute(pattern);
|
|
3871
3872
|
}
|
|
3872
3873
|
exports.isAbsolute = isAbsolute;
|
|
3873
3874
|
}));
|
|
@@ -4495,7 +4496,7 @@ var require_fs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4495
4496
|
//#region node_modules/@nodelib/fs.scandir/out/settings.js
|
|
4496
4497
|
var require_settings$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
4497
4498
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4498
|
-
const path$
|
|
4499
|
+
const path$4 = __require("path");
|
|
4499
4500
|
const fsStat = require_out$3();
|
|
4500
4501
|
const fs = require_fs();
|
|
4501
4502
|
var Settings = class {
|
|
@@ -4503,7 +4504,7 @@ var require_settings$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4503
4504
|
this._options = _options;
|
|
4504
4505
|
this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
|
|
4505
4506
|
this.fs = fs.createFileSystemAdapter(this._options.fs);
|
|
4506
|
-
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$
|
|
4507
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$4.sep);
|
|
4507
4508
|
this.stats = this._getValue(this._options.stats, false);
|
|
4508
4509
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
4509
4510
|
this.fsStatSettings = new fsStat.Settings({
|
|
@@ -5097,7 +5098,7 @@ var require_sync$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
5097
5098
|
//#region node_modules/@nodelib/fs.walk/out/settings.js
|
|
5098
5099
|
var require_settings$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5099
5100
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5100
|
-
const path$
|
|
5101
|
+
const path$3 = __require("path");
|
|
5101
5102
|
const fsScandir = require_out$2();
|
|
5102
5103
|
var Settings = class {
|
|
5103
5104
|
constructor(_options = {}) {
|
|
@@ -5107,7 +5108,7 @@ var require_settings$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
5107
5108
|
this.deepFilter = this._getValue(this._options.deepFilter, null);
|
|
5108
5109
|
this.entryFilter = this._getValue(this._options.entryFilter, null);
|
|
5109
5110
|
this.errorFilter = this._getValue(this._options.errorFilter, null);
|
|
5110
|
-
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$
|
|
5111
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$3.sep);
|
|
5111
5112
|
this.fsScandirSettings = new fsScandir.Settings({
|
|
5112
5113
|
followSymbolicLinks: this._options.followSymbolicLinks,
|
|
5113
5114
|
fs: this._options.fs,
|
|
@@ -5159,7 +5160,7 @@ var require_out$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
5159
5160
|
//#region node_modules/fast-glob/out/readers/reader.js
|
|
5160
5161
|
var require_reader = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5161
5162
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5162
|
-
const path$
|
|
5163
|
+
const path$2 = __require("path");
|
|
5163
5164
|
const fsStat = require_out$3();
|
|
5164
5165
|
const utils = require_utils$1();
|
|
5165
5166
|
var Reader = class {
|
|
@@ -5172,7 +5173,7 @@ var require_reader = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
5172
5173
|
});
|
|
5173
5174
|
}
|
|
5174
5175
|
_getFullEntryPath(filepath) {
|
|
5175
|
-
return path$
|
|
5176
|
+
return path$2.resolve(this._settings.cwd, filepath);
|
|
5176
5177
|
}
|
|
5177
5178
|
_makeEntry(stats, pattern) {
|
|
5178
5179
|
const entry = {
|
|
@@ -5507,7 +5508,7 @@ var require_entry = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
5507
5508
|
//#region node_modules/fast-glob/out/providers/provider.js
|
|
5508
5509
|
var require_provider = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5509
5510
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5510
|
-
const path$
|
|
5511
|
+
const path$1 = __require("path");
|
|
5511
5512
|
const deep_1 = require_deep();
|
|
5512
5513
|
const entry_1 = require_entry$1();
|
|
5513
5514
|
const error_1 = require_error();
|
|
@@ -5521,7 +5522,7 @@ var require_provider = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
5521
5522
|
this.entryTransformer = new entry_2.default(this._settings);
|
|
5522
5523
|
}
|
|
5523
5524
|
_getRootDirectory(task) {
|
|
5524
|
-
return path$
|
|
5525
|
+
return path$1.resolve(this._settings.cwd, task.base);
|
|
5525
5526
|
}
|
|
5526
5527
|
_getReaderOptions(task) {
|
|
5527
5528
|
const basePath = task.base === "." ? "" : task.base;
|
|
@@ -5852,7 +5853,7 @@ var import_out = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((export
|
|
|
5852
5853
|
* Async iterable filename pattern matcher
|
|
5853
5854
|
*/
|
|
5854
5855
|
async function* glob(dir, pattern, options = {}) {
|
|
5855
|
-
const absoluteDir =
|
|
5856
|
+
const absoluteDir = Path.resolve(dir);
|
|
5856
5857
|
const stats = await fsp.stat(absoluteDir);
|
|
5857
5858
|
for await (const entry of import_out.default.stream(pattern, {
|
|
5858
5859
|
...options,
|
|
@@ -6022,7 +6023,7 @@ var NextToLast = class {
|
|
|
6022
6023
|
};
|
|
6023
6024
|
}
|
|
6024
6025
|
decode(str) {
|
|
6025
|
-
let fileName =
|
|
6026
|
+
let fileName = Path.basename(str);
|
|
6026
6027
|
if (fileName.endsWith(this.extension)) fileName = fileName.substring(0, fileName.length - this.extension.length);
|
|
6027
6028
|
return CID.decode(this.base.decoder.decode(fileName));
|
|
6028
6029
|
}
|
|
@@ -6048,7 +6049,7 @@ var NextToLast = class {
|
|
|
6048
6049
|
async function writeFile$1(file, contents, options) {
|
|
6049
6050
|
try {
|
|
6050
6051
|
options?.signal?.throwIfAborted();
|
|
6051
|
-
await raceSignal(fsp.mkdir(
|
|
6052
|
+
await raceSignal(fsp.mkdir(Path.dirname(file), { recursive: true }), options?.signal);
|
|
6052
6053
|
const writer = new Writer(file);
|
|
6053
6054
|
options?.signal?.throwIfAborted();
|
|
6054
6055
|
await writer.write(contents);
|
|
@@ -6073,7 +6074,7 @@ var FsBlockstore = class {
|
|
|
6073
6074
|
deleteManyConcurrency;
|
|
6074
6075
|
shardingStrategy;
|
|
6075
6076
|
constructor(location, init = {}) {
|
|
6076
|
-
this.path =
|
|
6077
|
+
this.path = Path.resolve(location);
|
|
6077
6078
|
this.createIfMissing = init.createIfMissing ?? true;
|
|
6078
6079
|
this.errorIfExists = init.errorIfExists ?? false;
|
|
6079
6080
|
this.deleteManyConcurrency = init.deleteManyConcurrency ?? 50;
|
|
@@ -6099,7 +6100,7 @@ var FsBlockstore = class {
|
|
|
6099
6100
|
async put(key, val, options) {
|
|
6100
6101
|
const { dir, file } = this.shardingStrategy.encode(key);
|
|
6101
6102
|
try {
|
|
6102
|
-
await writeFile$1(
|
|
6103
|
+
await writeFile$1(Path.join(this.path, dir, file), val, options);
|
|
6103
6104
|
return key;
|
|
6104
6105
|
} catch (err) {
|
|
6105
6106
|
throw new PutFailedError(String(err));
|
|
@@ -6118,7 +6119,7 @@ var FsBlockstore = class {
|
|
|
6118
6119
|
let handle;
|
|
6119
6120
|
try {
|
|
6120
6121
|
options?.signal?.throwIfAborted();
|
|
6121
|
-
handle = await raceSignal(fsp.open(
|
|
6122
|
+
handle = await raceSignal(fsp.open(Path.join(this.path, dir, file)), options?.signal);
|
|
6122
6123
|
yield* handle.createReadStream();
|
|
6123
6124
|
} catch (err) {
|
|
6124
6125
|
if (handle != null) await raceSignal(handle.close(), options?.signal);
|
|
@@ -6139,7 +6140,7 @@ var FsBlockstore = class {
|
|
|
6139
6140
|
const { dir, file } = this.shardingStrategy.encode(key);
|
|
6140
6141
|
try {
|
|
6141
6142
|
options?.signal?.throwIfAborted();
|
|
6142
|
-
await raceSignal(fsp.unlink(
|
|
6143
|
+
await raceSignal(fsp.unlink(Path.join(this.path, dir, file)), options?.signal);
|
|
6143
6144
|
} catch (err) {
|
|
6144
6145
|
if (err.code === "ENOENT") return;
|
|
6145
6146
|
throw new DeleteFailedError(String(err));
|
|
@@ -6157,14 +6158,14 @@ var FsBlockstore = class {
|
|
|
6157
6158
|
const { dir, file } = this.shardingStrategy.encode(key);
|
|
6158
6159
|
try {
|
|
6159
6160
|
options?.signal?.throwIfAborted();
|
|
6160
|
-
await raceSignal(fsp.access(
|
|
6161
|
+
await raceSignal(fsp.access(Path.join(this.path, dir, file)), options?.signal);
|
|
6161
6162
|
} catch (err) {
|
|
6162
6163
|
return false;
|
|
6163
6164
|
}
|
|
6164
6165
|
return true;
|
|
6165
6166
|
}
|
|
6166
6167
|
async *getAll(options) {
|
|
6167
|
-
const pattern = `**/*${this.shardingStrategy.extension}`.split(
|
|
6168
|
+
const pattern = `**/*${this.shardingStrategy.extension}`.split(Path.sep).join("/");
|
|
6168
6169
|
const files = glob(this.path, pattern, { absolute: true });
|
|
6169
6170
|
for await (const file of files) try {
|
|
6170
6171
|
options?.signal?.throwIfAborted();
|
|
@@ -6216,7 +6217,7 @@ async function createBlockstoreForLibp2pJsClient({ dataPath, key }) {
|
|
|
6216
6217
|
defaultMaxBytes: DEFAULT_IN_MEMORY_BLOCKSTORE_MAX_BYTES,
|
|
6217
6218
|
close: async () => {}
|
|
6218
6219
|
};
|
|
6219
|
-
const store = new FsBlockstore(path
|
|
6220
|
+
const store = new FsBlockstore(path.join(dataPath, "blockstore", key));
|
|
6220
6221
|
await store.open();
|
|
6221
6222
|
return {
|
|
6222
6223
|
blockstore: store,
|
|
@@ -6451,11 +6452,7 @@ var Libp2pJsClient = class {
|
|
|
6451
6452
|
};
|
|
6452
6453
|
//#endregion
|
|
6453
6454
|
//#region dist/node/helia/dial-transport-filter.js
|
|
6454
|
-
const DENIED_DIAL_TRANSPORTS_BY_DEFAULT = [
|
|
6455
|
-
"webrtc",
|
|
6456
|
-
"webrtc-direct",
|
|
6457
|
-
"webtransport"
|
|
6458
|
-
];
|
|
6455
|
+
const DENIED_DIAL_TRANSPORTS_BY_DEFAULT = ["webrtc", "webrtc-direct"];
|
|
6459
6456
|
function multiaddrUsesDeniedTransport(multiaddr) {
|
|
6460
6457
|
const componentNames = multiaddr.getComponents().map((component) => component.name);
|
|
6461
6458
|
return DENIED_DIAL_TRANSPORTS_BY_DEFAULT.some((deniedProto) => componentNames.includes(deniedProto));
|
|
@@ -6464,6 +6461,37 @@ function createDefaultDialTransportGater() {
|
|
|
6464
6461
|
return { denyDialMultiaddr: (multiaddr) => multiaddrUsesDeniedTransport(multiaddr) };
|
|
6465
6462
|
}
|
|
6466
6463
|
//#endregion
|
|
6464
|
+
//#region dist/node/helia/dial-address-sorter.js
|
|
6465
|
+
function udpPreference(multiaddr) {
|
|
6466
|
+
const components = multiaddr.getComponents();
|
|
6467
|
+
const udp = components.find((component) => component.name === "udp");
|
|
6468
|
+
if (!udp) return void 0;
|
|
6469
|
+
if (udp.value === "443") return 0;
|
|
6470
|
+
const family = components[0]?.name;
|
|
6471
|
+
return family === "ip6" || family === "dns6" ? 1 : 2;
|
|
6472
|
+
}
|
|
6473
|
+
function certifiedAddressesFirst(a, b) {
|
|
6474
|
+
if (a.isCertified && !b.isCertified) return -1;
|
|
6475
|
+
if (!a.isCertified && b.isCertified) return 1;
|
|
6476
|
+
return 0;
|
|
6477
|
+
}
|
|
6478
|
+
function isIp6(multiaddr) {
|
|
6479
|
+
const family = multiaddr.getComponents()[0]?.name;
|
|
6480
|
+
return family === "ip6" || family === "dns6";
|
|
6481
|
+
}
|
|
6482
|
+
function preferredUdpAddressesFirst(a, b) {
|
|
6483
|
+
const preferenceA = udpPreference(a);
|
|
6484
|
+
const preferenceB = udpPreference(b);
|
|
6485
|
+
if (preferenceA === void 0 || preferenceB === void 0) return 0;
|
|
6486
|
+
if (preferenceA !== preferenceB) return preferenceA < preferenceB ? -1 : 1;
|
|
6487
|
+
const ip6A = isIp6(a);
|
|
6488
|
+
const ip6B = isIp6(b);
|
|
6489
|
+
if (ip6A && !ip6B) return -1;
|
|
6490
|
+
if (!ip6A && ip6B) return 1;
|
|
6491
|
+
return 0;
|
|
6492
|
+
}
|
|
6493
|
+
const pkcDialAddressSorter = (a, b) => loopbackAddressLast(a.multiaddr, b.multiaddr) || publicAddressesFirst(a.multiaddr, b.multiaddr) || circuitRelayAddressesLast(a.multiaddr, b.multiaddr) || certifiedAddressesFirst(a, b) || reliableTransportsFirst(a.multiaddr, b.multiaddr) || preferredUdpAddressesFirst(a.multiaddr, b.multiaddr);
|
|
6494
|
+
//#endregion
|
|
6467
6495
|
//#region dist/node/helia/helia-for-pkc.js
|
|
6468
6496
|
const log = logger_default("pkc-js:libp2p-js");
|
|
6469
6497
|
const libp2pJsClients = {};
|
|
@@ -6547,6 +6575,7 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
|
|
|
6547
6575
|
transports: [...libp2pDefaults().transports ?? [], ...extraLibp2pTransports],
|
|
6548
6576
|
connectionMonitor: { abortConnectionOnPingFailure: false },
|
|
6549
6577
|
connectionGater: createDefaultDialTransportGater(),
|
|
6578
|
+
connectionManager: { addressSorter: pkcDialAddressSorter },
|
|
6550
6579
|
...pkcOptions.libp2pOptions,
|
|
6551
6580
|
services: {
|
|
6552
6581
|
identify: identify(),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createNewLocalCommunityDb, r as updateInstancePropsWithStartedCommunityOrDb, t as LocalCommunity } from "./local-community-
|
|
1
|
+
import { n as createNewLocalCommunityDb, r as updateInstancePropsWithStartedCommunityOrDb, t as LocalCommunity } from "./local-community-BIYHcGS5.js";
|
|
2
2
|
export { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { i as __toESM } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as retryKuboIpfsAddAndProvide, $n as CommentEditsTableRowSchema, At as ChallengeAnswerMessageSchema, Bt as DecryptedChallengeRequestSchema, C as hideClassPrivateProps, Ct as trackUpdatingCommunity, Dt as require_sha256, En as VotePubsubReservedFields, Et as untrackUpdatingCommunity, F as isLinkOfVideo, G as removeMfsFilesSafely, Hn as CommentsTableRowSchema, I as isLinkValid, It as ChallengeVerificationMessageSchema, Jt as version_default, Lr as PKCError, M as isLinkOfAudio, Mn as CommentPubsubMessageReservedFields, Mt as ChallengeMessageSchema, N as isLinkOfImage, On as VoteTablesRowSchema, Or as t$4, P as isLinkOfMedia, Pt as ChallengeRequestMessageSchema, Rr as messages, Sr as e, T as ipnsNameToIpnsOverPubsubTopic, Tn as VotePubsubMessagePublicationSchema, Tr as t$3, Vn as CommentUpdateTableRowSchema, W as removeBlocksFromKuboNode, Xn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Xt as CommunityEditPublicationPubsubReservedFields, Yn as CommentEditPubsubMessagePublicationSchema, Z as retryKuboBlockPutPinAndProvidePubsubTopic, Zn as CommentEditReservedFields, _ as genToArray, _r as t$7, at as timestamp, b as getIpnsRecordInLocalKuboNode, br as t$6, bt as syncCommunityRegistryEntry, c as contentContainsMarkdownImages, ct as withSortedKeysDeep, dt as findStartedCommunity, f as derivePublicationFromChallengeRequest, g as findMalformedUnicodeString, gr as n$3, hr as isStringDomain, i as calculateStringSizeSameAsIpfsAddCidV0, in as CommentModerationsTableRowSchema, ir as AuthorReservedFields, j as isLinkOfAnimatedImage, jn as CommentIpfsSchema, jr as require_retry, kr as t$2, kt as pTimeout, l as contentContainsMarkdownVideos, lt as writeKuboFilesWithTimeout, mn as CommunitySignedPropertyNames, nn as CommentModerationReservedFields, nt as sleepUntilTimeoutOrAbort, o as calculateUnixFsDagSizeCidV0, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, q as removeNullUndefinedValues, r as calculateIpfsCidV0, rt as statMfsPathSafely, s as contentContainsMarkdownAudio, st as withSortedKeys, ti as ZodError, tn as CommentModerationPubsubMessagePublicationSchema, ut as findCommunityInRegistry, v as getEquivalentCommunityAddresses, vr as n$2, wr as r$1, wt as untrackStartedCommunity, xr as e$1, xt as trackStartedCommunity, y as getErrorCodeFromMessage, yr as t$5, z as pubsubTopicToDhtKey, zn as CommentUpdateSchema, zr as logger_default, zt as DecryptedChallengeRequestPublicationSchema } from "./util-
|
|
3
|
-
import { $ as createSchemaRowParser, An as verifyChallengeAnswer, Bn as verifyCommunityEdit, Br as t$8, Cr as getThumbnailPropsOfLink, Dr as moveCommunityDbToDeletedDirectory, Dt as parseJsonWithPKCErrorIfFails, En as signCommunity, Fn as verifyCommentIpfs, Fr as isCommunityStartLocked, Gr as stringify, Hn as verifyVote, Hr as n$4, In as verifyCommentModeration, Ir as require_src, Kn as getAuthorNameFromWire, Ln as verifyCommentPubsubMessage, Lr as t$10, Mn as verifyChallengeRequest, Mr as findCommunitiesEntry, N as MAX_PAGE_SIZE_BYTES, Or as refreshCommunitiesList, Pn as verifyCommentEdit, Q as collectSchemaRowCoercions, Qn as effectiveMaxCrosspostDepth, Rn as verifyCommentUpdate, Rr as t$11, S as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, Sn as signCommentEdit, Tn as signCommentUpdateForChallengeVerification, Un as buildRuntimeAuthor, Vr as n$5, W as pLimit, Wn as cleanWireAuthor, Wr as t$9, X as coerceSchemaRowBoolean, Xr as STORAGE_KEYS, Z as coerceSchemaRowJson, Zn as crosspostChainDepthUpTo, Zr as require_lodash_merge, _ as createAuthorIdentityMatcher, _r as deriveCommentIpfsFromCommentTableRow, a as generatePagesReportingFailedSorts, ar as encode, b as KeyvBetterSqlite3, bn as signChallengeVerification, c as resolvePageSortsOrThrow, cn as SignerWithPublicKeyAddress, cr as getPKCAddressFromPublicKey, d as getChallengeVerification, dr as BackupAbortError, dt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, f as getCommunityChallengeFromCommunityChallengeSettings, fn as decryptEd25519AesGcmPublicKeyBuffer, fr as backupCommunityDb, g as authorNameResolveFailureReason, gn as cleanUpBeforePublishing, gr as deleteOldCommunityInWindows, h as authorIdentityMatcherForRequest, hn as _validateSignatureOfPKCRecord, i as derivePublicPageSorts, ir as decode, j as iterateOverPageCidsToFindAllCids, kr as resolveDbPostsCidRefs, lr as getPKCAddressFromPublicKeySync, m as pkcJsChallenges, mn as encryptEd25519AesGcmPublicKeyBuffer, mr as calculateInlineRepliesBudget, nr as getCommunityPublicKeyFromWire, o as loadPageSortsForStartedCommunity, p as loadChallengeFileFromCommunityChallengeSettings, pr as calculateExpectedSignatureSize, pt as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, r as computePageSortsFingerprint, s as lookupPageSortFactories, sr as getIpfsKeyFromPrivateKey, t as RpcLocalCommunity, tr as getCommunityNameFromWire, u as deriveCommunityChallengesOrThrow, ur as getPublicKeyFromPrivateKey, v as TrackedInstanceRegistry, vn as signChallengeMessage, vr as deriveDbPosts, w as TIMEFRAMES_TO_SECONDS, wn as signCommentUpdate, wr as importSignerIntoKuboNode, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, xn as signComment, xr as getDefaultCommunityDbConfig, y as LRUCache, yr as deriveDbReplies, zn as verifyCommunity, zr as r$2 } from "./rpc-local-community-
|
|
4
|
-
import { a as scorePageCommentsWithFile, i as partitionPageCommentsForSort, n as filterRepliesForPageSort, o as stripRepliesFromPageComment, r as orderPageCommentsByScore, t as createDescendantsLookup } from "./page-sort-scoring-
|
|
2
|
+
import { $ as retryKuboIpfsAddAndProvide, $n as CommentEditsTableRowSchema, At as ChallengeAnswerMessageSchema, Bt as DecryptedChallengeRequestSchema, C as hideClassPrivateProps, Ct as trackUpdatingCommunity, Dt as require_sha256, En as VotePubsubReservedFields, Et as untrackUpdatingCommunity, F as isLinkOfVideo, G as removeMfsFilesSafely, Hn as CommentsTableRowSchema, I as isLinkValid, It as ChallengeVerificationMessageSchema, Jt as version_default, Lr as PKCError, M as isLinkOfAudio, Mn as CommentPubsubMessageReservedFields, Mt as ChallengeMessageSchema, N as isLinkOfImage, On as VoteTablesRowSchema, Or as t$4, P as isLinkOfMedia, Pt as ChallengeRequestMessageSchema, Rr as messages, Sr as e, T as ipnsNameToIpnsOverPubsubTopic, Tn as VotePubsubMessagePublicationSchema, Tr as t$3, Vn as CommentUpdateTableRowSchema, W as removeBlocksFromKuboNode, Xn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Xt as CommunityEditPublicationPubsubReservedFields, Yn as CommentEditPubsubMessagePublicationSchema, Z as retryKuboBlockPutPinAndProvidePubsubTopic, Zn as CommentEditReservedFields, _ as genToArray, _r as t$7, at as timestamp, b as getIpnsRecordInLocalKuboNode, br as t$6, bt as syncCommunityRegistryEntry, c as contentContainsMarkdownImages, ct as withSortedKeysDeep, dt as findStartedCommunity, f as derivePublicationFromChallengeRequest, g as findMalformedUnicodeString, gr as n$3, hr as isStringDomain, i as calculateStringSizeSameAsIpfsAddCidV0, in as CommentModerationsTableRowSchema, ir as AuthorReservedFields, j as isLinkOfAnimatedImage, jn as CommentIpfsSchema, jr as require_retry, kr as t$2, kt as pTimeout, l as contentContainsMarkdownVideos, lt as writeKuboFilesWithTimeout, mn as CommunitySignedPropertyNames, nn as CommentModerationReservedFields, nt as sleepUntilTimeoutOrAbort, o as calculateUnixFsDagSizeCidV0, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, q as removeNullUndefinedValues, r as calculateIpfsCidV0, rt as statMfsPathSafely, s as contentContainsMarkdownAudio, st as withSortedKeys, ti as ZodError, tn as CommentModerationPubsubMessagePublicationSchema, ut as findCommunityInRegistry, v as getEquivalentCommunityAddresses, vr as n$2, wr as r$1, wt as untrackStartedCommunity, xr as e$1, xt as trackStartedCommunity, y as getErrorCodeFromMessage, yr as t$5, z as pubsubTopicToDhtKey, zn as CommentUpdateSchema, zr as logger_default, zt as DecryptedChallengeRequestPublicationSchema } from "./util-DkGqBo7o.js";
|
|
3
|
+
import { $ as createSchemaRowParser, An as verifyChallengeAnswer, Bn as verifyCommunityEdit, Br as t$8, Cr as getThumbnailPropsOfLink, Dr as moveCommunityDbToDeletedDirectory, Dt as parseJsonWithPKCErrorIfFails, En as signCommunity, Fn as verifyCommentIpfs, Fr as isCommunityStartLocked, Gr as stringify, Hn as verifyVote, Hr as n$4, In as verifyCommentModeration, Ir as require_src, Kn as getAuthorNameFromWire, Ln as verifyCommentPubsubMessage, Lr as t$10, Mn as verifyChallengeRequest, Mr as findCommunitiesEntry, N as MAX_PAGE_SIZE_BYTES, Or as refreshCommunitiesList, Pn as verifyCommentEdit, Q as collectSchemaRowCoercions, Qn as effectiveMaxCrosspostDepth, Rn as verifyCommentUpdate, Rr as t$11, S as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, Sn as signCommentEdit, Tn as signCommentUpdateForChallengeVerification, Un as buildRuntimeAuthor, Vr as n$5, W as pLimit, Wn as cleanWireAuthor, Wr as t$9, X as coerceSchemaRowBoolean, Xr as STORAGE_KEYS, Z as coerceSchemaRowJson, Zn as crosspostChainDepthUpTo, Zr as require_lodash_merge, _ as createAuthorIdentityMatcher, _r as deriveCommentIpfsFromCommentTableRow, a as generatePagesReportingFailedSorts, ar as encode, b as KeyvBetterSqlite3, bn as signChallengeVerification, c as resolvePageSortsOrThrow, cn as SignerWithPublicKeyAddress, cr as getPKCAddressFromPublicKey, d as getChallengeVerification, dr as BackupAbortError, dt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, f as getCommunityChallengeFromCommunityChallengeSettings, fn as decryptEd25519AesGcmPublicKeyBuffer, fr as backupCommunityDb, g as authorNameResolveFailureReason, gn as cleanUpBeforePublishing, gr as deleteOldCommunityInWindows, h as authorIdentityMatcherForRequest, hn as _validateSignatureOfPKCRecord, i as derivePublicPageSorts, ir as decode, j as iterateOverPageCidsToFindAllCids, kr as resolveDbPostsCidRefs, lr as getPKCAddressFromPublicKeySync, m as pkcJsChallenges, mn as encryptEd25519AesGcmPublicKeyBuffer, mr as calculateInlineRepliesBudget, nr as getCommunityPublicKeyFromWire, o as loadPageSortsForStartedCommunity, p as loadChallengeFileFromCommunityChallengeSettings, pr as calculateExpectedSignatureSize, pt as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, r as computePageSortsFingerprint, s as lookupPageSortFactories, sr as getIpfsKeyFromPrivateKey, t as RpcLocalCommunity, tr as getCommunityNameFromWire, u as deriveCommunityChallengesOrThrow, ur as getPublicKeyFromPrivateKey, v as TrackedInstanceRegistry, vn as signChallengeMessage, vr as deriveDbPosts, w as TIMEFRAMES_TO_SECONDS, wn as signCommentUpdate, wr as importSignerIntoKuboNode, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, xn as signComment, xr as getDefaultCommunityDbConfig, y as LRUCache, yr as deriveDbReplies, zn as verifyCommunity, zr as r$2 } from "./rpc-local-community-BHMWTLg2.js";
|
|
4
|
+
import { a as scorePageCommentsWithFile, i as partitionPageCommentsForSort, n as filterRepliesForPageSort, o as stripRepliesFromPageComment, r as orderPageCommentsByScore, t as createDescendantsLookup } from "./page-sort-scoring-I74ngMaI.js";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
-
import
|
|
6
|
+
import Path from "node:path";
|
|
7
7
|
import os from "os";
|
|
8
8
|
import fs, { existsSync, promises } from "node:fs";
|
|
9
|
-
import path
|
|
9
|
+
import path from "path";
|
|
10
10
|
import assert from "assert";
|
|
11
11
|
import { Buffer as Buffer$1 } from "buffer";
|
|
12
12
|
import fs$1 from "fs";
|
|
@@ -315,15 +315,15 @@ async function throwIfChallengeSettingsAreInvalid({ challengeSettings, pkc, comm
|
|
|
315
315
|
const processStartedCommunities = new TrackedInstanceRegistry();
|
|
316
316
|
function normalizeRegistryDataPath(dataPath) {
|
|
317
317
|
if (dataPath === void 0) return void 0;
|
|
318
|
-
const resolved = path
|
|
318
|
+
const resolved = path.resolve(dataPath);
|
|
319
319
|
let existing = resolved;
|
|
320
320
|
let tail = "";
|
|
321
321
|
while (true) try {
|
|
322
|
-
return path
|
|
322
|
+
return path.join(fs$1.realpathSync.native(existing), tail);
|
|
323
323
|
} catch {
|
|
324
|
-
const parent = path
|
|
324
|
+
const parent = path.dirname(existing);
|
|
325
325
|
if (parent === existing) return resolved;
|
|
326
|
-
tail = path
|
|
326
|
+
tail = path.join(path.basename(existing), tail);
|
|
327
327
|
existing = parent;
|
|
328
328
|
}
|
|
329
329
|
}
|
|
@@ -365,6 +365,20 @@ function pageBytes(entrySizes, hasNextCid) {
|
|
|
365
365
|
return bytes;
|
|
366
366
|
}
|
|
367
367
|
const pageDagSize = (entrySizes, hasNextCid) => calculateUnixFsDagSizeCidV0(pageBytes(entrySizes, hasNextCid));
|
|
368
|
+
const pageByteBudgets = /* @__PURE__ */ new Map();
|
|
369
|
+
function pageByteBudget(dagSizeLimit) {
|
|
370
|
+
const cached = pageByteBudgets.get(dagSizeLimit);
|
|
371
|
+
if (cached !== void 0) return cached;
|
|
372
|
+
let fits = 0;
|
|
373
|
+
let high = Math.max(dagSizeLimit, 0);
|
|
374
|
+
while (fits < high) {
|
|
375
|
+
const middle = Math.ceil((fits + high) / 2);
|
|
376
|
+
if (calculateUnixFsDagSizeCidV0(middle) <= dagSizeLimit) fits = middle;
|
|
377
|
+
else high = middle - 1;
|
|
378
|
+
}
|
|
379
|
+
pageByteBudgets.set(dagSizeLimit, fits);
|
|
380
|
+
return fits;
|
|
381
|
+
}
|
|
368
382
|
const SERIALIZE_BATCH = 256;
|
|
369
383
|
function serializedEntryCacheBudgetBytes() {
|
|
370
384
|
const heapLimit = v8.getHeapStatistics().heap_size_limit;
|
|
@@ -588,31 +602,32 @@ var PageGenerator = class {
|
|
|
588
602
|
const entryBytes = new Array(comments.length);
|
|
589
603
|
for (let i = 0; i < comments.length; i++) entryBytes[i] = bytesOf(comments[i]);
|
|
590
604
|
if (pageDagSize(entryBytes, false) <= FIRST_PAGE_SIZE) return [comments];
|
|
591
|
-
const
|
|
592
|
-
const
|
|
605
|
+
const WRAPPER_WITH_CID_BYTES = pageBytes([], true);
|
|
606
|
+
const WRAPPER_WITHOUT_CID_BYTES = pageBytes([], false);
|
|
593
607
|
const chunks = [];
|
|
594
608
|
let currentChunk = [];
|
|
595
609
|
let chunkIndex = 0;
|
|
596
|
-
let
|
|
610
|
+
let accumulatedBytes = WRAPPER_WITH_CID_BYTES;
|
|
597
611
|
const getCurrentMaxSize = (index) => index === 0 ? FIRST_PAGE_SIZE : Math.min(MB * Math.pow(2, index - 1), MAX_PAGE_SIZE_BYTES);
|
|
598
612
|
for (let i = 0; i < comments.length; i++) {
|
|
599
|
-
const
|
|
613
|
+
const commentBytes = entryBytes[i];
|
|
600
614
|
const maxSize = getCurrentMaxSize(chunkIndex);
|
|
615
|
+
const byteBudget = pageByteBudget(maxSize - SAFETY_MARGIN);
|
|
601
616
|
const isLastItem = i === comments.length - 1;
|
|
602
617
|
const commaSize = currentChunk.length > 0 ? 1 : 0;
|
|
603
|
-
if (
|
|
618
|
+
if (accumulatedBytes + commaSize + commentBytes > byteBudget) {
|
|
604
619
|
if (currentChunk.length > 0) {
|
|
605
620
|
chunks.push(currentChunk);
|
|
606
621
|
currentChunk = [];
|
|
607
622
|
chunkIndex++;
|
|
608
|
-
|
|
609
|
-
} else if (
|
|
610
|
-
logger_default("pkc-js:page-generator:_chunkComments").trace(`Single comment at index ${i} (
|
|
611
|
-
|
|
623
|
+
accumulatedBytes = isLastItem ? WRAPPER_WITHOUT_CID_BYTES : WRAPPER_WITH_CID_BYTES;
|
|
624
|
+
} else if (commentBytes > byteBudget) {
|
|
625
|
+
logger_default("pkc-js:page-generator:_chunkComments").trace(`Single comment at index ${i} (${commentBytes} bytes) is large relative to page size limit (${maxSize}) for page ${chunkIndex}`);
|
|
626
|
+
accumulatedBytes = isLastItem ? WRAPPER_WITHOUT_CID_BYTES : WRAPPER_WITH_CID_BYTES;
|
|
612
627
|
}
|
|
613
628
|
}
|
|
614
629
|
currentChunk.push(comments[i]);
|
|
615
|
-
|
|
630
|
+
accumulatedBytes += commaSize + commentBytes;
|
|
616
631
|
}
|
|
617
632
|
if (currentChunk.length > 0) chunks.push(currentChunk);
|
|
618
633
|
return chunks;
|
|
@@ -1707,9 +1722,9 @@ var DbHandler = class {
|
|
|
1707
1722
|
if (needToMigrate) {
|
|
1708
1723
|
if (dbExistsAlready && currentDbVersion > 0) {
|
|
1709
1724
|
this.destoryConnection();
|
|
1710
|
-
backupDbPath = path
|
|
1711
|
-
log(`Copying db ${path
|
|
1712
|
-
if (!fs$1.existsSync(path
|
|
1725
|
+
backupDbPath = path.join(path.dirname(dbPath), ".backup_before_migration", `${path.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
|
|
1726
|
+
log(`Copying db ${path.basename(dbPath)} to ${backupDbPath} before migration`);
|
|
1727
|
+
if (!fs$1.existsSync(path.dirname(backupDbPath))) await fs$1.promises.mkdir(path.dirname(backupDbPath), { recursive: true });
|
|
1713
1728
|
const sourceDb = new Database(dbPath, { fileMustExist: true });
|
|
1714
1729
|
await sourceDb.backup(backupDbPath);
|
|
1715
1730
|
sourceDb.close();
|
|
@@ -3760,10 +3775,10 @@ var DbHandler = class {
|
|
|
3760
3775
|
if (this._db || this._keyv) await this.destoryConnection();
|
|
3761
3776
|
this._transactionDepth = 0;
|
|
3762
3777
|
const dataPath = this._community._pkc.dataPath;
|
|
3763
|
-
const oldPathString = path
|
|
3764
|
-
const newPathString = path
|
|
3765
|
-
await fs$1.promises.mkdir(path
|
|
3766
|
-
await fs$1.promises.mkdir(path
|
|
3778
|
+
const oldPathString = path.join(dataPath, "communities", oldDbName);
|
|
3779
|
+
const newPathString = path.join(dataPath, "communities", newDbName);
|
|
3780
|
+
await fs$1.promises.mkdir(path.dirname(oldPathString), { recursive: true });
|
|
3781
|
+
await fs$1.promises.mkdir(path.dirname(newPathString), { recursive: true });
|
|
3767
3782
|
try {
|
|
3768
3783
|
if (!fs$1.existsSync(oldPathString)) log(`Old DB file ${oldPathString} does not exist. Cannot backup/rename.`);
|
|
3769
3784
|
else {
|
|
@@ -3785,8 +3800,8 @@ var DbHandler = class {
|
|
|
3785
3800
|
}
|
|
3786
3801
|
async lockCommunityStart(communityAddress = this._community.address) {
|
|
3787
3802
|
const log = logger_default("pkc-js:local-community:db-handler:lock:start");
|
|
3788
|
-
const lockfilePath = path
|
|
3789
|
-
const communityDbPath = path
|
|
3803
|
+
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
3804
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
3790
3805
|
try {
|
|
3791
3806
|
await import_src.default.lock(communityDbPath, {
|
|
3792
3807
|
lockfilePath,
|
|
@@ -3807,8 +3822,8 @@ var DbHandler = class {
|
|
|
3807
3822
|
async unlockCommunityStart(communityAddress = this._community.address) {
|
|
3808
3823
|
const log = logger_default("pkc-js:local-community:db-handler:unlock:start");
|
|
3809
3824
|
log.trace(`Attempting to unlock the start of community (${communityAddress})`);
|
|
3810
|
-
const lockfilePath = path
|
|
3811
|
-
const communityDbPath = path
|
|
3825
|
+
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
3826
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
3812
3827
|
if (!fs$1.existsSync(lockfilePath) || !fs$1.existsSync(communityDbPath)) return;
|
|
3813
3828
|
try {
|
|
3814
3829
|
await import_src.default.unlock(communityDbPath, { lockfilePath });
|
|
@@ -3826,8 +3841,8 @@ var DbHandler = class {
|
|
|
3826
3841
|
}
|
|
3827
3842
|
async lockCommunityState() {
|
|
3828
3843
|
const log = logger_default("pkc-js:local-community:db-handler:lock:lockCommunityState");
|
|
3829
|
-
const lockfilePath = path
|
|
3830
|
-
const communityDbPath = path
|
|
3844
|
+
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
3845
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
3831
3846
|
try {
|
|
3832
3847
|
await import_src.default.lock(communityDbPath, {
|
|
3833
3848
|
lockfilePath,
|
|
@@ -3844,8 +3859,8 @@ var DbHandler = class {
|
|
|
3844
3859
|
}
|
|
3845
3860
|
async unlockCommunityState() {
|
|
3846
3861
|
const log = logger_default("pkc-js:local-community:db-handler:lock:unlockCommunityState");
|
|
3847
|
-
const lockfilePath = path
|
|
3848
|
-
const communityDbPath = path
|
|
3862
|
+
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
3863
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
3849
3864
|
if (!fs$1.existsSync(lockfilePath)) return;
|
|
3850
3865
|
try {
|
|
3851
3866
|
await import_src.default.unlock(communityDbPath, { lockfilePath });
|
|
@@ -3855,7 +3870,7 @@ var DbHandler = class {
|
|
|
3855
3870
|
}
|
|
3856
3871
|
}
|
|
3857
3872
|
communityDbExists() {
|
|
3858
|
-
const communityDbPath = path
|
|
3873
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
3859
3874
|
return fs$1.existsSync(communityDbPath);
|
|
3860
3875
|
}
|
|
3861
3876
|
markCommentsAsPublishedToPostUpdates(commentCids) {
|
|
@@ -6255,7 +6270,7 @@ function normalizeSelfAddrsForProvider(addrs, peerId) {
|
|
|
6255
6270
|
return n$3(addrs.map((addr) => addr.endsWith(suffix) ? addr.slice(0, -suffix.length) : addr));
|
|
6256
6271
|
}
|
|
6257
6272
|
function isBrowserDialableAddr(addr) {
|
|
6258
|
-
return addr.includes("/webrtc") || addr.includes("/ws");
|
|
6273
|
+
return addr.includes("/webrtc") || addr.includes("/ws") || addr.includes("/webtransport") && addr.includes("/certhash/");
|
|
6259
6274
|
}
|
|
6260
6275
|
async function getBrowserDialableSelfAddrs(client) {
|
|
6261
6276
|
const idRes = await client.id();
|
|
@@ -6267,7 +6282,7 @@ function connectionCriticalCids(community) {
|
|
|
6267
6282
|
return n$3([community.pubsubTopicRoutingCid, community.ipnsPubsubTopicRoutingCid].filter((cid) => typeof cid === "string"));
|
|
6268
6283
|
}
|
|
6269
6284
|
/**
|
|
6270
|
-
* Re-provide the connection-critical CIDs when the node's browser-dialable (WSS/WebRTC) self-addresses
|
|
6285
|
+
* Re-provide the connection-critical CIDs when the node's browser-dialable (WSS/WebRTC/WebTransport) self-addresses
|
|
6271
6286
|
* have changed since the last provide. This pushes the current addresses to the HTTP routers so browsers
|
|
6272
6287
|
* don't get NoValidAddressesError against stale/dead addresses.
|
|
6273
6288
|
*
|
|
@@ -6868,10 +6883,10 @@ async function restoreCommunityAfterFailedRename({ community, oldAddress, newAdd
|
|
|
6868
6883
|
}
|
|
6869
6884
|
}
|
|
6870
6885
|
async function removePartialDbCopy({ community, oldAddress, newAddress, log }) {
|
|
6871
|
-
const communitiesPath =
|
|
6872
|
-
if (!fs.existsSync(
|
|
6886
|
+
const communitiesPath = Path.join(community._pkc.dataPath, "communities");
|
|
6887
|
+
if (!fs.existsSync(Path.join(communitiesPath, oldAddress))) return;
|
|
6873
6888
|
try {
|
|
6874
|
-
await fs.promises.rm(
|
|
6889
|
+
await fs.promises.rm(Path.join(communitiesPath, newAddress), { force: true });
|
|
6875
6890
|
} catch (e) {
|
|
6876
6891
|
log.error(`Failed to remove the partial DB copy of community (${oldAddress}) at ${newAddress}`, e);
|
|
6877
6892
|
}
|
|
@@ -7015,11 +7030,11 @@ async function edit(community, newCommunityOptions) {
|
|
|
7015
7030
|
const EXPORTS_KEY = STORAGE_KEYS[STORAGE_KEYS.EXPORTS];
|
|
7016
7031
|
function defaultExportPathFor(community, exportId) {
|
|
7017
7032
|
if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
|
|
7018
|
-
return
|
|
7033
|
+
return Path.join(community._pkc.dataPath, "exports", `${exportId}.sqlite`);
|
|
7019
7034
|
}
|
|
7020
7035
|
function sourceDbPathFor(community) {
|
|
7021
7036
|
if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
|
|
7022
|
-
return
|
|
7037
|
+
return Path.join(community._pkc.dataPath, "communities", community.address);
|
|
7023
7038
|
}
|
|
7024
7039
|
async function persistExports(community) {
|
|
7025
7040
|
if (!community._dbHandler) return;
|
|
@@ -7095,9 +7110,9 @@ async function runExportTask(community, exportId, opts) {
|
|
|
7095
7110
|
async function exportCommunityEmbedded(community, options = {}) {
|
|
7096
7111
|
if (options.signal?.aborted) throw options.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
7097
7112
|
const exportId = v4();
|
|
7098
|
-
const destPath = options.exportPath ?
|
|
7113
|
+
const destPath = options.exportPath ? Path.resolve(options.exportPath) : defaultExportPathFor(community, exportId);
|
|
7099
7114
|
const includePrivateKey = options.includePrivateKey === true;
|
|
7100
|
-
if (
|
|
7115
|
+
if (Path.resolve(destPath) === Path.resolve(sourceDbPathFor(community))) throw new PKCError("ERR_EXPORT_PATH_TARGETS_LIVE_DB", {
|
|
7101
7116
|
communityAddress: community.address,
|
|
7102
7117
|
exportPath: destPath
|
|
7103
7118
|
});
|