shogun-core 4.0.2 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -148187,25 +148187,24 @@ class CoreInitializer {
148187
148187
  /**
148188
148188
  * Initialize Gun instance
148189
148189
  */
148190
+ // Sì, è corretto.
148190
148191
  async initializeGun(config) {
148191
148192
  try {
148192
148193
  let peers = await (0, shogun_relays_1.forceListUpdate)();
148193
- if (config.gunOptions?.peers && config.gunOptions?.peers.length === 0) {
148194
+ if (config.gunOptions?.peers &&
148195
+ (config.gunOptions?.peers?.length === 0 || !config.gunOptions?.peers) &&
148196
+ !config.gunInstance) {
148197
+ console.log("Using peers from forceListUpdate", peers);
148194
148198
  config.gunOptions.peers = peers;
148195
148199
  }
148196
- if (config.gunInstance && config.gunOptions === undefined) {
148200
+ if (config.gunInstance) {
148197
148201
  this.core._gun = config.gunInstance;
148198
148202
  }
148199
148203
  else if (config.gunOptions && config.gunInstance === undefined) {
148200
148204
  this.core._gun = (0, gundb_1.createGun)(config.gunOptions);
148201
148205
  }
148202
148206
  else if (config.gunInstance && config.gunOptions) {
148203
- this.core._gun = config.gunInstance;
148204
- }
148205
- else {
148206
- this.core._gun = (0, gundb_1.createGun)({
148207
- peers: config.gunOptions?.peers || peers,
148208
- });
148207
+ throw new Error("Gun instance and gun options cannot be provided together");
148209
148208
  }
148210
148209
  }
148211
148210
  catch (error) {