@pkcprotocol/pkc-js 0.0.126 → 0.0.128

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.
Files changed (65) hide show
  1. package/dist/browser/clients/base-client-manager.d.ts +8 -0
  2. package/dist/browser/clients/base-client-manager.js +39 -2
  3. package/dist/browser/clients/base-client-manager.js.map +1 -1
  4. package/dist/browser/community/community-client-manager.js +2 -1
  5. package/dist/browser/community/community-client-manager.js.map +1 -1
  6. package/dist/browser/generated-version.d.ts +1 -1
  7. package/dist/browser/generated-version.js +1 -1
  8. package/dist/browser/helia/helia-for-pkc.js +88 -22
  9. package/dist/browser/helia/helia-for-pkc.js.map +1 -1
  10. package/dist/browser/helia/types.d.ts +4 -1
  11. package/dist/browser/pages/page-size.d.ts +2 -0
  12. package/dist/browser/pages/page-size.js +11 -0
  13. package/dist/browser/pages/page-size.js.map +1 -0
  14. package/dist/browser/pages/pages-client-manager.js +2 -1
  15. package/dist/browser/pages/pages-client-manager.js.map +1 -1
  16. package/dist/browser/pages/util.js +3 -2
  17. package/dist/browser/pages/util.js.map +1 -1
  18. package/dist/browser/publications/comment/comment-client-manager.d.ts +5 -2
  19. package/dist/browser/publications/comment/comment-client-manager.js +104 -40
  20. package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
  21. package/dist/browser/publications/comment/comment.d.ts +4 -0
  22. package/dist/browser/publications/comment/comment.js +4 -0
  23. package/dist/browser/publications/comment/comment.js.map +1 -1
  24. package/dist/browser/runtime/node/community/page-generator.js +8 -7
  25. package/dist/browser/runtime/node/community/page-generator.js.map +1 -1
  26. package/dist/bundled/bundle-manifest.json +47 -46
  27. package/dist/bundled/challenges.js +1 -1
  28. package/dist/bundled/chunks/{helia-for-pkc-vQZvQcs_.js → helia-for-pkc-6kkeZX1a.js} +123 -69
  29. package/dist/bundled/chunks/{local-community-51NzNBUS.js → local-community-B79BAYRo.js} +34 -35
  30. package/dist/bundled/chunks/{local-community-dcM1R3k5.js → local-community-BST1U_f3.js} +1 -1
  31. package/dist/bundled/chunks/{node-agDtcKUp.js → node-BEH8NA_I.js} +108 -32
  32. package/dist/bundled/chunks/{page-sort-scoring-BSBLegpC.js → page-sort-scoring-2FkqYYNf.js} +1 -1
  33. package/dist/bundled/chunks/{rpc-local-community-DOcUqswi.js → rpc-local-community-SmLDPm1j.js} +44 -9
  34. package/dist/bundled/chunks/{util-PGPkG-gU.js → util-LwSS90AE.js} +1 -1
  35. package/dist/bundled/chunks/{util-DNYbha6W.js → util-jyIDYw_Q.js} +1 -1
  36. package/dist/bundled/chunks/{validate-package-factories-2U8SCIxZ.js → validate-package-factories-_KKnb8At.js} +2 -2
  37. package/dist/bundled/index.js +1 -1
  38. package/dist/bundled/page-sorts.js +1 -1
  39. package/dist/bundled/rpc/src/index.js +4 -4
  40. package/dist/node/clients/base-client-manager.d.ts +8 -0
  41. package/dist/node/clients/base-client-manager.js +39 -2
  42. package/dist/node/clients/base-client-manager.js.map +1 -1
  43. package/dist/node/community/community-client-manager.js +2 -1
  44. package/dist/node/community/community-client-manager.js.map +1 -1
  45. package/dist/node/generated-version.d.ts +1 -1
  46. package/dist/node/generated-version.js +1 -1
  47. package/dist/node/helia/helia-for-pkc.js +88 -22
  48. package/dist/node/helia/helia-for-pkc.js.map +1 -1
  49. package/dist/node/helia/types.d.ts +4 -1
  50. package/dist/node/pages/page-size.d.ts +2 -0
  51. package/dist/node/pages/page-size.js +11 -0
  52. package/dist/node/pages/page-size.js.map +1 -0
  53. package/dist/node/pages/pages-client-manager.js +2 -1
  54. package/dist/node/pages/pages-client-manager.js.map +1 -1
  55. package/dist/node/pages/util.js +3 -2
  56. package/dist/node/pages/util.js.map +1 -1
  57. package/dist/node/publications/comment/comment-client-manager.d.ts +5 -2
  58. package/dist/node/publications/comment/comment-client-manager.js +104 -40
  59. package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
  60. package/dist/node/publications/comment/comment.d.ts +4 -0
  61. package/dist/node/publications/comment/comment.js +4 -0
  62. package/dist/node/publications/comment/comment.js.map +1 -1
  63. package/dist/node/runtime/node/community/page-generator.js +8 -7
  64. package/dist/node/runtime/node/community/page-generator.js.map +1 -1
  65. package/package.json +1 -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-PGPkG-gU.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-DNYbha6W.js";
2
+ import { C as hideClassPrivateProps, Lr as PKCError, T as ipnsNameToIpnsOverPubsubTopic, n as binaryKeyToPubsubTopic, zr as logger_default } from "./util-LwSS90AE.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-jyIDYw_Q.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
- import fsp, { rename, writeFile } from "node:fs/promises";
8
- import Path, { basename, dirname, join } from "node:path";
9
- import path from "path";
7
+ import fs, { rename, writeFile } from "node:fs/promises";
8
+ import path, { basename, dirname, join } from "node:path";
9
+ import path$1 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";
@@ -151,7 +151,7 @@ var require_path = /* @__PURE__ */ __commonJSMin(((exports) => {
151
151
  Object.defineProperty(exports, "__esModule", { value: true });
152
152
  exports.convertPosixPathToPattern = exports.convertWindowsPathToPattern = exports.convertPathToPattern = exports.escapePosixPath = exports.escapeWindowsPath = exports.escape = exports.removeLeadingDotSegment = exports.makeAbsolute = exports.unixify = void 0;
153
153
  const os$1 = __require("os");
154
- const path$9 = __require("path");
154
+ const path$10 = __require("path");
155
155
  const IS_WINDOWS_PLATFORM = os$1.platform() === "win32";
156
156
  const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
157
157
  /**
@@ -180,7 +180,7 @@ var require_path = /* @__PURE__ */ __commonJSMin(((exports) => {
180
180
  }
181
181
  exports.unixify = unixify;
182
182
  function makeAbsolute(cwd, filepath) {
183
- return path$9.resolve(cwd, filepath);
183
+ return path$10.resolve(cwd, filepath);
184
184
  }
185
185
  exports.makeAbsolute = makeAbsolute;
186
186
  function removeLeadingDotSegment(entry) {
@@ -1432,7 +1432,7 @@ var require_braces = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1432
1432
  //#endregion
1433
1433
  //#region node_modules/picomatch/lib/constants.js
1434
1434
  var require_constants$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1435
- const path$8 = __require("path");
1435
+ const path$9 = __require("path");
1436
1436
  const WIN_SLASH = "\\\\/";
1437
1437
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
1438
1438
  const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
@@ -1557,7 +1557,7 @@ var require_constants$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1557
1557
  CHAR_UNDERSCORE: 95,
1558
1558
  CHAR_VERTICAL_LINE: 124,
1559
1559
  CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
1560
- SEP: path$8.sep,
1560
+ SEP: path$9.sep,
1561
1561
  /**
1562
1562
  * Create EXTGLOB_CHARS
1563
1563
  */
@@ -1601,7 +1601,7 @@ var require_constants$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1601
1601
  //#endregion
1602
1602
  //#region node_modules/picomatch/lib/utils.js
1603
1603
  var require_utils$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
1604
- const path$7 = __require("path");
1604
+ const path$8 = __require("path");
1605
1605
  const win32 = process.platform === "win32";
1606
1606
  const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants$1();
1607
1607
  exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
@@ -1621,7 +1621,7 @@ var require_utils$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
1621
1621
  };
1622
1622
  exports.isWindows = (options) => {
1623
1623
  if (options && typeof options.windows === "boolean") return options.windows;
1624
- return win32 === true || path$7.sep === "\\";
1624
+ return win32 === true || path$8.sep === "\\";
1625
1625
  };
1626
1626
  exports.escapeLast = (input, char, lastIdx) => {
1627
1627
  const idx = input.lastIndexOf(char, lastIdx);
@@ -2991,7 +2991,7 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2991
2991
  //#endregion
2992
2992
  //#region node_modules/picomatch/lib/picomatch.js
2993
2993
  var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2994
- const path$6 = __require("path");
2994
+ const path$7 = __require("path");
2995
2995
  const scan = require_scan();
2996
2996
  const parse = require_parse();
2997
2997
  const utils = require_utils$2();
@@ -3130,7 +3130,7 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3130
3130
  * @api public
3131
3131
  */
3132
3132
  picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
3133
- return (glob instanceof RegExp ? glob : picomatch.makeRe(glob, options)).test(path$6.basename(input));
3133
+ return (glob instanceof RegExp ? glob : picomatch.makeRe(glob, options)).test(path$7.basename(input));
3134
3134
  };
3135
3135
  /**
3136
3136
  * Returns true if **any** of the given glob `patterns` match the specified `string`.
@@ -3685,7 +3685,7 @@ var require_micromatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3685
3685
  var require_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
3686
3686
  Object.defineProperty(exports, "__esModule", { value: true });
3687
3687
  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$5 = __require("path");
3688
+ const path$6 = __require("path");
3689
3689
  const globParent = require_glob_parent();
3690
3690
  const micromatch = require_micromatch();
3691
3691
  const GLOBSTAR = "**";
@@ -3793,7 +3793,7 @@ var require_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
3793
3793
  }
3794
3794
  exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
3795
3795
  function isAffectDepthOfReadingPattern(pattern) {
3796
- const basename = path$5.basename(pattern);
3796
+ const basename = path$6.basename(pattern);
3797
3797
  return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
3798
3798
  }
3799
3799
  exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
@@ -3867,7 +3867,7 @@ var require_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
3867
3867
  }
3868
3868
  exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
3869
3869
  function isAbsolute(pattern) {
3870
- return path$5.isAbsolute(pattern);
3870
+ return path$6.isAbsolute(pattern);
3871
3871
  }
3872
3872
  exports.isAbsolute = isAbsolute;
3873
3873
  }));
@@ -4153,12 +4153,12 @@ var require_sync$5 = /* @__PURE__ */ __commonJSMin(((exports) => {
4153
4153
  var require_fs$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
4154
4154
  Object.defineProperty(exports, "__esModule", { value: true });
4155
4155
  exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
4156
- const fs$2 = __require("fs");
4156
+ const fs$3 = __require("fs");
4157
4157
  exports.FILE_SYSTEM_ADAPTER = {
4158
- lstat: fs$2.lstat,
4159
- stat: fs$2.stat,
4160
- lstatSync: fs$2.lstatSync,
4161
- statSync: fs$2.statSync
4158
+ lstat: fs$3.lstat,
4159
+ stat: fs$3.stat,
4160
+ lstatSync: fs$3.lstatSync,
4161
+ statSync: fs$3.statSync
4162
4162
  };
4163
4163
  function createFileSystemAdapter(fsMethods) {
4164
4164
  if (fsMethods === void 0) return exports.FILE_SYSTEM_ADAPTER;
@@ -4476,14 +4476,14 @@ var require_sync$4 = /* @__PURE__ */ __commonJSMin(((exports) => {
4476
4476
  var require_fs = /* @__PURE__ */ __commonJSMin(((exports) => {
4477
4477
  Object.defineProperty(exports, "__esModule", { value: true });
4478
4478
  exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
4479
- const fs$1 = __require("fs");
4479
+ const fs$2 = __require("fs");
4480
4480
  exports.FILE_SYSTEM_ADAPTER = {
4481
- lstat: fs$1.lstat,
4482
- stat: fs$1.stat,
4483
- lstatSync: fs$1.lstatSync,
4484
- statSync: fs$1.statSync,
4485
- readdir: fs$1.readdir,
4486
- readdirSync: fs$1.readdirSync
4481
+ lstat: fs$2.lstat,
4482
+ stat: fs$2.stat,
4483
+ lstatSync: fs$2.lstatSync,
4484
+ statSync: fs$2.statSync,
4485
+ readdir: fs$2.readdir,
4486
+ readdirSync: fs$2.readdirSync
4487
4487
  };
4488
4488
  function createFileSystemAdapter(fsMethods) {
4489
4489
  if (fsMethods === void 0) return exports.FILE_SYSTEM_ADAPTER;
@@ -4495,7 +4495,7 @@ var require_fs = /* @__PURE__ */ __commonJSMin(((exports) => {
4495
4495
  //#region node_modules/@nodelib/fs.scandir/out/settings.js
4496
4496
  var require_settings$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
4497
4497
  Object.defineProperty(exports, "__esModule", { value: true });
4498
- const path$4 = __require("path");
4498
+ const path$5 = __require("path");
4499
4499
  const fsStat = require_out$3();
4500
4500
  const fs = require_fs();
4501
4501
  var Settings = class {
@@ -4503,7 +4503,7 @@ var require_settings$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
4503
4503
  this._options = _options;
4504
4504
  this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
4505
4505
  this.fs = fs.createFileSystemAdapter(this._options.fs);
4506
- this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$4.sep);
4506
+ this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$5.sep);
4507
4507
  this.stats = this._getValue(this._options.stats, false);
4508
4508
  this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
4509
4509
  this.fsStatSettings = new fsStat.Settings({
@@ -5097,7 +5097,7 @@ var require_sync$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
5097
5097
  //#region node_modules/@nodelib/fs.walk/out/settings.js
5098
5098
  var require_settings$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
5099
5099
  Object.defineProperty(exports, "__esModule", { value: true });
5100
- const path$3 = __require("path");
5100
+ const path$4 = __require("path");
5101
5101
  const fsScandir = require_out$2();
5102
5102
  var Settings = class {
5103
5103
  constructor(_options = {}) {
@@ -5107,7 +5107,7 @@ var require_settings$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
5107
5107
  this.deepFilter = this._getValue(this._options.deepFilter, null);
5108
5108
  this.entryFilter = this._getValue(this._options.entryFilter, null);
5109
5109
  this.errorFilter = this._getValue(this._options.errorFilter, null);
5110
- this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$3.sep);
5110
+ this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$4.sep);
5111
5111
  this.fsScandirSettings = new fsScandir.Settings({
5112
5112
  followSymbolicLinks: this._options.followSymbolicLinks,
5113
5113
  fs: this._options.fs,
@@ -5159,7 +5159,7 @@ var require_out$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
5159
5159
  //#region node_modules/fast-glob/out/readers/reader.js
5160
5160
  var require_reader = /* @__PURE__ */ __commonJSMin(((exports) => {
5161
5161
  Object.defineProperty(exports, "__esModule", { value: true });
5162
- const path$2 = __require("path");
5162
+ const path$3 = __require("path");
5163
5163
  const fsStat = require_out$3();
5164
5164
  const utils = require_utils$1();
5165
5165
  var Reader = class {
@@ -5172,7 +5172,7 @@ var require_reader = /* @__PURE__ */ __commonJSMin(((exports) => {
5172
5172
  });
5173
5173
  }
5174
5174
  _getFullEntryPath(filepath) {
5175
- return path$2.resolve(this._settings.cwd, filepath);
5175
+ return path$3.resolve(this._settings.cwd, filepath);
5176
5176
  }
5177
5177
  _makeEntry(stats, pattern) {
5178
5178
  const entry = {
@@ -5507,7 +5507,7 @@ var require_entry = /* @__PURE__ */ __commonJSMin(((exports) => {
5507
5507
  //#region node_modules/fast-glob/out/providers/provider.js
5508
5508
  var require_provider = /* @__PURE__ */ __commonJSMin(((exports) => {
5509
5509
  Object.defineProperty(exports, "__esModule", { value: true });
5510
- const path$1 = __require("path");
5510
+ const path$2 = __require("path");
5511
5511
  const deep_1 = require_deep();
5512
5512
  const entry_1 = require_entry$1();
5513
5513
  const error_1 = require_error();
@@ -5521,7 +5521,7 @@ var require_provider = /* @__PURE__ */ __commonJSMin(((exports) => {
5521
5521
  this.entryTransformer = new entry_2.default(this._settings);
5522
5522
  }
5523
5523
  _getRootDirectory(task) {
5524
- return path$1.resolve(this._settings.cwd, task.base);
5524
+ return path$2.resolve(this._settings.cwd, task.base);
5525
5525
  }
5526
5526
  _getReaderOptions(task) {
5527
5527
  const basePath = task.base === "." ? "" : task.base;
@@ -5677,7 +5677,7 @@ var require_sync = /* @__PURE__ */ __commonJSMin(((exports) => {
5677
5677
  var require_settings = /* @__PURE__ */ __commonJSMin(((exports) => {
5678
5678
  Object.defineProperty(exports, "__esModule", { value: true });
5679
5679
  exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
5680
- const fs = __require("fs");
5680
+ const fs$1 = __require("fs");
5681
5681
  const os = __require("os");
5682
5682
  /**
5683
5683
  * The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
@@ -5685,12 +5685,12 @@ var require_settings = /* @__PURE__ */ __commonJSMin(((exports) => {
5685
5685
  */
5686
5686
  const CPU_COUNT = Math.max(os.cpus().length, 1);
5687
5687
  exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
5688
- lstat: fs.lstat,
5689
- lstatSync: fs.lstatSync,
5690
- stat: fs.stat,
5691
- statSync: fs.statSync,
5692
- readdir: fs.readdir,
5693
- readdirSync: fs.readdirSync
5688
+ lstat: fs$1.lstat,
5689
+ lstatSync: fs$1.lstatSync,
5690
+ stat: fs$1.stat,
5691
+ statSync: fs$1.statSync,
5692
+ readdir: fs$1.readdir,
5693
+ readdirSync: fs$1.readdirSync
5694
5694
  };
5695
5695
  var Settings = class {
5696
5696
  constructor(_options = {}) {
@@ -5852,8 +5852,8 @@ var import_out = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((export
5852
5852
  * Async iterable filename pattern matcher
5853
5853
  */
5854
5854
  async function* glob(dir, pattern, options = {}) {
5855
- const absoluteDir = Path.resolve(dir);
5856
- const stats = await fsp.stat(absoluteDir);
5855
+ const absoluteDir = path.resolve(dir);
5856
+ const stats = await fs.stat(absoluteDir);
5857
5857
  for await (const entry of import_out.default.stream(pattern, {
5858
5858
  ...options,
5859
5859
  cwd: stats.isDirectory() ? dir : process.cwd()
@@ -6022,7 +6022,7 @@ var NextToLast = class {
6022
6022
  };
6023
6023
  }
6024
6024
  decode(str) {
6025
- let fileName = Path.basename(str);
6025
+ let fileName = path.basename(str);
6026
6026
  if (fileName.endsWith(this.extension)) fileName = fileName.substring(0, fileName.length - this.extension.length);
6027
6027
  return CID.decode(this.base.decoder.decode(fileName));
6028
6028
  }
@@ -6048,14 +6048,14 @@ var NextToLast = class {
6048
6048
  async function writeFile$1(file, contents, options) {
6049
6049
  try {
6050
6050
  options?.signal?.throwIfAborted();
6051
- await raceSignal(fsp.mkdir(Path.dirname(file), { recursive: true }), options?.signal);
6051
+ await raceSignal(fs.mkdir(path.dirname(file), { recursive: true }), options?.signal);
6052
6052
  const writer = new Writer(file);
6053
6053
  options?.signal?.throwIfAborted();
6054
6054
  await writer.write(contents);
6055
6055
  } catch (err) {
6056
6056
  if (err.syscall === "rename" && ["ENOENT", "EPERM"].includes(err.code)) {
6057
6057
  options?.signal?.throwIfAborted();
6058
- await raceSignal(fsp.access(file, fsp.constants.F_OK | fsp.constants.W_OK), options?.signal);
6058
+ await raceSignal(fs.access(file, fs.constants.F_OK | fs.constants.W_OK), options?.signal);
6059
6059
  return;
6060
6060
  }
6061
6061
  throw err;
@@ -6073,7 +6073,7 @@ var FsBlockstore = class {
6073
6073
  deleteManyConcurrency;
6074
6074
  shardingStrategy;
6075
6075
  constructor(location, init = {}) {
6076
- this.path = Path.resolve(location);
6076
+ this.path = path.resolve(location);
6077
6077
  this.createIfMissing = init.createIfMissing ?? true;
6078
6078
  this.errorIfExists = init.errorIfExists ?? false;
6079
6079
  this.deleteManyConcurrency = init.deleteManyConcurrency ?? 50;
@@ -6083,11 +6083,11 @@ var FsBlockstore = class {
6083
6083
  }
6084
6084
  async open() {
6085
6085
  try {
6086
- await fsp.access(this.path, fsp.constants.F_OK | fsp.constants.W_OK);
6086
+ await fs.access(this.path, fs.constants.F_OK | fs.constants.W_OK);
6087
6087
  if (this.errorIfExists) throw new OpenFailedError(`Blockstore directory: ${this.path} already exists`);
6088
6088
  } catch (err) {
6089
6089
  if (err.code === "ENOENT") if (this.createIfMissing) {
6090
- await fsp.mkdir(this.path, { recursive: true });
6090
+ await fs.mkdir(this.path, { recursive: true });
6091
6091
  return;
6092
6092
  } else throw new OpenFailedError(`Blockstore directory: ${this.path} does not exist`);
6093
6093
  throw err;
@@ -6099,7 +6099,7 @@ var FsBlockstore = class {
6099
6099
  async put(key, val, options) {
6100
6100
  const { dir, file } = this.shardingStrategy.encode(key);
6101
6101
  try {
6102
- await writeFile$1(Path.join(this.path, dir, file), val, options);
6102
+ await writeFile$1(path.join(this.path, dir, file), val, options);
6103
6103
  return key;
6104
6104
  } catch (err) {
6105
6105
  throw new PutFailedError(String(err));
@@ -6118,7 +6118,7 @@ var FsBlockstore = class {
6118
6118
  let handle;
6119
6119
  try {
6120
6120
  options?.signal?.throwIfAborted();
6121
- handle = await raceSignal(fsp.open(Path.join(this.path, dir, file)), options?.signal);
6121
+ handle = await raceSignal(fs.open(path.join(this.path, dir, file)), options?.signal);
6122
6122
  yield* handle.createReadStream();
6123
6123
  } catch (err) {
6124
6124
  if (handle != null) await raceSignal(handle.close(), options?.signal);
@@ -6139,7 +6139,7 @@ var FsBlockstore = class {
6139
6139
  const { dir, file } = this.shardingStrategy.encode(key);
6140
6140
  try {
6141
6141
  options?.signal?.throwIfAborted();
6142
- await raceSignal(fsp.unlink(Path.join(this.path, dir, file)), options?.signal);
6142
+ await raceSignal(fs.unlink(path.join(this.path, dir, file)), options?.signal);
6143
6143
  } catch (err) {
6144
6144
  if (err.code === "ENOENT") return;
6145
6145
  throw new DeleteFailedError(String(err));
@@ -6157,14 +6157,14 @@ var FsBlockstore = class {
6157
6157
  const { dir, file } = this.shardingStrategy.encode(key);
6158
6158
  try {
6159
6159
  options?.signal?.throwIfAborted();
6160
- await raceSignal(fsp.access(Path.join(this.path, dir, file)), options?.signal);
6160
+ await raceSignal(fs.access(path.join(this.path, dir, file)), options?.signal);
6161
6161
  } catch (err) {
6162
6162
  return false;
6163
6163
  }
6164
6164
  return true;
6165
6165
  }
6166
6166
  async *getAll(options) {
6167
- const pattern = `**/*${this.shardingStrategy.extension}`.split(Path.sep).join("/");
6167
+ const pattern = `**/*${this.shardingStrategy.extension}`.split(path.sep).join("/");
6168
6168
  const files = glob(this.path, pattern, { absolute: true });
6169
6169
  for await (const file of files) try {
6170
6170
  options?.signal?.throwIfAborted();
@@ -6173,7 +6173,7 @@ var FsBlockstore = class {
6173
6173
  bytes: (async function* () {
6174
6174
  let handle;
6175
6175
  try {
6176
- handle = await raceSignal(fsp.open(file), options?.signal);
6176
+ handle = await raceSignal(fs.open(file), options?.signal);
6177
6177
  yield* handle.createReadStream();
6178
6178
  } finally {
6179
6179
  if (handle != null) await raceSignal(handle.close(), options?.signal);
@@ -6216,7 +6216,7 @@ async function createBlockstoreForLibp2pJsClient({ dataPath, key }) {
6216
6216
  defaultMaxBytes: DEFAULT_IN_MEMORY_BLOCKSTORE_MAX_BYTES,
6217
6217
  close: async () => {}
6218
6218
  };
6219
- const store = new FsBlockstore(path.join(dataPath, "blockstore", key));
6219
+ const store = new FsBlockstore(path$1.join(dataPath, "blockstore", key));
6220
6220
  await store.open();
6221
6221
  return {
6222
6222
  blockstore: store,
@@ -6632,6 +6632,20 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
6632
6632
  }, ms);
6633
6633
  signal.addEventListener("abort", onAbort, { once: true });
6634
6634
  });
6635
+ const createSeededBitswapSession = (rootCid, scopeIpnsPubsubTopic) => {
6636
+ const session = helia.blockstore.createSession(rootCid, { providers: getBitswapSessionSeedPeers(scopeIpnsPubsubTopic).map((peerId) => peerId.toCID()) });
6637
+ const sessionGet = session.get.bind(session);
6638
+ const fallbackGet = helia.blockstore.get.bind(helia.blockstore);
6639
+ session.get = (blockCid, blockGetOptions) => fetchBlockWithStalledSessionFailover({
6640
+ cid: blockCid,
6641
+ sessionGet,
6642
+ fallbackGet,
6643
+ stallTimeoutMs: heliaWithKuboRpcClientShape._bitswapSessionStalledGetFailoverMs ?? 2500,
6644
+ options: blockGetOptions,
6645
+ log
6646
+ });
6647
+ return session;
6648
+ };
6635
6649
  const ipnsPubsubRouter = pubSubIPNSRouting(helia);
6636
6650
  const ipnsNameResolver = ipns(helia, { routers: [ipnsPubsubRouter] });
6637
6651
  for (let i = ipnsNameResolver.routers.length - 1; i >= 0; i--) if (isLocalStoreIpnsRouter(ipnsNameResolver.routers[i])) ipnsNameResolver.routers.splice(i, 1);
@@ -6916,17 +6930,7 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
6916
6930
  })), timeoutMs) : void 0;
6917
6931
  try {
6918
6932
  for (let attempt = 0;; attempt++) {
6919
- const session = helia.blockstore.createSession(rootCid, { providers: getBitswapSessionSeedPeers(bitswapSessionSeedScopeIpnsPubsubTopic).map((peerId) => peerId.toCID()) });
6920
- const sessionGet = session.get.bind(session);
6921
- const fallbackGet = helia.blockstore.get.bind(helia.blockstore);
6922
- session.get = (blockCid, blockGetOptions) => fetchBlockWithStalledSessionFailover({
6923
- cid: blockCid,
6924
- sessionGet,
6925
- fallbackGet,
6926
- stallTimeoutMs: heliaWithKuboRpcClientShape._bitswapSessionStalledGetFailoverMs ?? 2500,
6927
- options: blockGetOptions,
6928
- log
6929
- });
6933
+ const session = createSeededBitswapSession(rootCid, bitswapSessionSeedScopeIpnsPubsubTopic);
6930
6934
  let yieldedAnyBytes = false;
6931
6935
  try {
6932
6936
  const catIterable = unixfs({ blockstore: session }).cat(rootCid, {
@@ -6991,6 +6995,56 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
6991
6995
  if (pubsubEventHandler.listenerCount(topic) === 0) helia.libp2p.services.pubsub.unsubscribe(topic);
6992
6996
  }
6993
6997
  },
6998
+ async resolve(ipfsPath, options) {
6999
+ throwIfHeliaIsStoppingOrStopped();
7000
+ const [rootCidString, ...subPathSegments] = ipfsPath.replace(/^\/ipfs\//, "").split("/");
7001
+ const timeoutMs = parseKuboStyleTimeoutMs(options?.timeout);
7002
+ const controller = new AbortController();
7003
+ const callerSignal = options?.signal;
7004
+ const abortFromCaller = () => controller.abort(callerSignal?.reason);
7005
+ const abortFromStop = () => controller.abort(new PKCError("ERR_HELIAS_STOPPING_OR_STOPPED", {
7006
+ heliaKey: pkcOptions.key,
7007
+ ipfsPath
7008
+ }));
7009
+ if (callerSignal?.aborted) abortFromCaller();
7010
+ else callerSignal?.addEventListener("abort", abortFromCaller, { once: true });
7011
+ if (catStopController.signal.aborted) abortFromStop();
7012
+ else catStopController.signal.addEventListener("abort", abortFromStop, { once: true });
7013
+ const timeoutTimer = timeoutMs !== void 0 ? setTimeout(() => controller.abort(new PKCError("ERR_FETCH_CID_P2P_TIMEOUT", {
7014
+ ipfsPath,
7015
+ timeoutMs
7016
+ })), timeoutMs) : void 0;
7017
+ try {
7018
+ const rootCid = CID.parse(rootCidString);
7019
+ for (let attempt = 0;; attempt++) {
7020
+ const session = createSeededBitswapSession(rootCid, options?.bitswapSessionSeedScopeIpnsPubsubTopic);
7021
+ try {
7022
+ return `/ipfs/${(await unixfs({ blockstore: session }).stat(rootCid, {
7023
+ path: subPathSegments.length > 0 ? subPathSegments.join("/") : void 0,
7024
+ signal: controller.signal
7025
+ })).cid.toString()}`;
7026
+ } catch (e) {
7027
+ if (controller.signal.aborted) throw controller.signal.reason instanceof Error ? controller.signal.reason : e;
7028
+ if (!isCausedByInsufficientProviders(e)) throw e;
7029
+ log.trace("Bitswap session found no providers for", ipfsPath, "- retrying, attempt", attempt + 1);
7030
+ } finally {
7031
+ session.close();
7032
+ }
7033
+ await delayAbortable(Math.min(SESSION_NO_PROVIDERS_RETRY_BASE_DELAY_MS * 2 ** attempt, 8e3), controller.signal);
7034
+ if (controller.signal.aborted) {
7035
+ if (controller.signal.reason instanceof Error) throw controller.signal.reason;
7036
+ throw new PKCError("ERR_FETCH_CID_P2P_TIMEOUT", {
7037
+ ipfsPath,
7038
+ timeoutMs
7039
+ });
7040
+ }
7041
+ }
7042
+ } finally {
7043
+ if (timeoutTimer) clearTimeout(timeoutTimer);
7044
+ callerSignal?.removeEventListener("abort", abortFromCaller);
7045
+ catStopController.signal.removeEventListener("abort", abortFromStop);
7046
+ }
7047
+ },
6994
7048
  async add(entry, options) {
6995
7049
  throw Error("Helia 'add' is not supported at the moment in pkc-js API");
6996
7050
  },