shogun-button-react 4.1.1 → 4.2.2

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 CHANGED
@@ -633,7 +633,7 @@ interface ShogunConnectorResult {
633
633
  getCurrentProviderUrl: () => string | null;
634
634
  registerPlugin: (plugin: any) => boolean;
635
635
  hasPlugin: (name: string) => boolean;
636
- gunPlugin: GunAdvancedPlugin;
636
+ gunPlugin: null;
637
637
  }
638
638
  ```
639
639
 
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import { ShogunCore } from "shogun-core";
3
3
  import { Observable } from "rxjs";
4
- import { GunAdvancedPlugin } from "../plugins/GunAdvancedPlugin";
5
4
  import "../styles/index.css";
6
5
  type ShogunContextType = {
7
6
  core: ShogunCore | null;
@@ -18,19 +17,7 @@ type ShogunContextType = {
18
17
  getPlugin: <T>(name: string) => T | undefined;
19
18
  exportGunPair: (password?: string) => Promise<string>;
20
19
  importGunPair: (pairData: string, password?: string) => Promise<boolean>;
21
- gunPlugin: GunAdvancedPlugin | null;
22
- useGunState: <T>(path: string, defaultValue?: T) => any;
23
- useGunCollection: <T>(path: string, options?: any) => any;
24
- useGunConnection: (path: string) => {
25
- isConnected: boolean;
26
- lastSeen: Date | null;
27
- error: string | null;
28
- };
29
- useGunDebug: (path: string, enabled?: boolean) => void;
30
- useGunRealtime: <T>(path: string, callback?: (data: T, key: string) => void) => {
31
- data: T | null;
32
- key: string | null;
33
- };
20
+ gunPlugin: null;
34
21
  put: (path: string, data: any) => Promise<void>;
35
22
  get: (path: string) => any;
36
23
  remove: (path: string) => Promise<void>;
@@ -1,6 +1,5 @@
1
1
  import React, { useContext, useState, createContext, useEffect, useRef, } from "react";
2
2
  import { Observable } from "rxjs";
3
- import { GunAdvancedPlugin } from "../plugins/GunAdvancedPlugin";
4
3
  import "../styles/index.css";
5
4
  // Default context
6
5
  const defaultShogunContext = {
@@ -19,11 +18,6 @@ const defaultShogunContext = {
19
18
  exportGunPair: async () => "",
20
19
  importGunPair: async () => false,
21
20
  gunPlugin: null,
22
- useGunState: () => ({}),
23
- useGunCollection: () => ({}),
24
- useGunConnection: () => ({ isConnected: false, lastSeen: null, error: null }),
25
- useGunDebug: () => { },
26
- useGunRealtime: () => ({ data: null, key: null }),
27
21
  put: async () => { },
28
22
  get: () => null,
29
23
  remove: async () => { },
@@ -376,32 +370,10 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
376
370
  throw new Error(`Failed to import Gun pair: ${error.message}`);
377
371
  }
378
372
  };
379
- // Inizializza il plugin
380
- const gunPlugin = React.useMemo(() => {
381
- if (!core)
382
- return null;
383
- return new GunAdvancedPlugin(core, {
384
- enableDebug: options.enableGunDebug !== false,
385
- enableConnectionMonitoring: options.enableConnectionMonitoring !== false,
386
- defaultPageSize: options.defaultPageSize || 20,
387
- connectionTimeout: options.connectionTimeout || 10000,
388
- debounceInterval: options.debounceInterval || 100,
389
- });
390
- }, [core, options]);
391
- // Effetto per pulizia del plugin
392
- React.useEffect(() => {
393
- return () => {
394
- if (gunPlugin) {
395
- gunPlugin.cleanup();
396
- }
397
- };
398
- }, [gunPlugin]);
399
- // Crea gli hook del plugin
400
- const pluginHooks = React.useMemo(() => {
401
- if (!gunPlugin)
402
- return {};
403
- return gunPlugin.createHooks();
404
- }, [gunPlugin]);
373
+ // Plugin initialization removed - GunAdvancedPlugin no longer available
374
+ const gunPlugin = null;
375
+ // Plugin hooks removed - GunAdvancedPlugin no longer available
376
+ const pluginHooks = {};
405
377
  // Create a properly typed context value
406
378
  const contextValue = React.useMemo(() => ({
407
379
  core,
@@ -419,49 +391,35 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
419
391
  importGunPair,
420
392
  setProvider,
421
393
  gunPlugin,
422
- // Ensure all required hooks are present with proper fallbacks
423
- useGunState: pluginHooks.useGunState ||
424
- (() => ({
425
- data: null,
426
- isLoading: false,
427
- error: null,
428
- update: async () => { },
429
- set: async () => { },
430
- remove: async () => { },
431
- refresh: () => { },
432
- })),
433
- useGunCollection: pluginHooks.useGunCollection ||
434
- (() => ({
435
- items: [],
436
- currentPage: 0,
437
- totalPages: 0,
438
- hasNextPage: false,
439
- hasPrevPage: false,
440
- nextPage: () => { },
441
- prevPage: () => { },
442
- goToPage: () => { },
443
- isLoading: false,
444
- error: null,
445
- refresh: () => { },
446
- addItem: async () => { },
447
- updateItem: async () => { },
448
- removeItem: async () => { },
449
- })),
450
- useGunConnection: pluginHooks.useGunConnection ||
451
- (() => ({
452
- isConnected: false,
453
- lastSeen: null,
454
- error: null,
455
- })),
456
- useGunDebug: pluginHooks.useGunDebug || (() => { }),
457
- useGunRealtime: pluginHooks.useGunRealtime ||
458
- (() => ({
459
- data: null,
460
- key: null,
461
- })),
462
- put: (gunPlugin === null || gunPlugin === void 0 ? void 0 : gunPlugin.put.bind(gunPlugin)) || (async () => { }),
463
- get: (gunPlugin === null || gunPlugin === void 0 ? void 0 : gunPlugin.get.bind(gunPlugin)) || (() => null),
464
- remove: (gunPlugin === null || gunPlugin === void 0 ? void 0 : gunPlugin.remove.bind(gunPlugin)) || (async () => { }),
394
+ put: async (path, data) => {
395
+ if (!(core === null || core === void 0 ? void 0 : core.gun))
396
+ throw new Error('Gun instance not available');
397
+ return new Promise((resolve, reject) => {
398
+ core.gun.get(path).put(data, (ack) => {
399
+ if (ack.err)
400
+ reject(new Error(ack.err));
401
+ else
402
+ resolve();
403
+ });
404
+ });
405
+ },
406
+ get: (path) => {
407
+ if (!(core === null || core === void 0 ? void 0 : core.gun))
408
+ return null;
409
+ return core.gun.get(path);
410
+ },
411
+ remove: async (path) => {
412
+ if (!(core === null || core === void 0 ? void 0 : core.gun))
413
+ throw new Error('Gun instance not available');
414
+ return new Promise((resolve, reject) => {
415
+ core.gun.get(path).put(null, (ack) => {
416
+ if (ack.err)
417
+ reject(new Error(ack.err));
418
+ else
419
+ resolve();
420
+ });
421
+ });
422
+ },
465
423
  }), [
466
424
  core,
467
425
  options,
package/dist/connector.js CHANGED
@@ -1,16 +1,27 @@
1
1
  import { ShogunCore } from "shogun-core";
2
- import { GunAdvancedPlugin } from "./plugins/GunAdvancedPlugin";
3
2
  export function shogunConnector(options) {
4
3
  const { gunInstance, gunOptions, appName, timeouts, webauthn, nostr, web3, zkproof, showWebauthn, showNostr, showMetamask, showZkProof, darkMode, enableGunDebug = true, enableConnectionMonitoring = true, defaultPageSize = 20, connectionTimeout = 10000, debounceInterval = 100, ...restOptions } = options;
5
- const core = new ShogunCore({
6
- gunOptions: gunOptions || undefined,
7
- gunInstance: gunInstance || undefined,
8
- webauthn,
9
- nostr,
10
- web3,
11
- zkproof,
12
- timeouts,
13
- });
4
+ let core = null;
5
+ if (gunInstance !== undefined) {
6
+ core = new ShogunCore({
7
+ gunInstance: gunInstance,
8
+ webauthn,
9
+ nostr,
10
+ web3,
11
+ zkproof,
12
+ timeouts,
13
+ });
14
+ }
15
+ else {
16
+ core = new ShogunCore({
17
+ gunOptions: gunOptions,
18
+ webauthn,
19
+ nostr,
20
+ web3,
21
+ zkproof,
22
+ timeouts,
23
+ });
24
+ }
14
25
  const setProvider = (provider) => {
15
26
  var _a;
16
27
  if (!core) {
@@ -48,8 +59,8 @@ export function shogunConnector(options) {
48
59
  var _a;
49
60
  const gun = ((_a = core === null || core === void 0 ? void 0 : core.db) === null || _a === void 0 ? void 0 : _a.gun) || (core === null || core === void 0 ? void 0 : core.gun);
50
61
  try {
51
- const peersObj = gun && gun.back ? gun.back('opt.peers') : undefined;
52
- const urls = peersObj && typeof peersObj === 'object' ? Object.keys(peersObj) : [];
62
+ const peersObj = gun && gun.back ? gun.back("opt.peers") : undefined;
63
+ const urls = peersObj && typeof peersObj === "object" ? Object.keys(peersObj) : [];
53
64
  return urls.length > 0 ? urls[0] : null;
54
65
  }
55
66
  catch {
@@ -72,22 +83,7 @@ export function shogunConnector(options) {
72
83
  const hasPlugin = (name) => {
73
84
  return core ? core.hasPlugin(name) : false;
74
85
  };
75
- // Registra automaticamente il plugin Gun avanzato
76
- let gunPlugin = null;
77
- if (core) {
78
- gunPlugin = new GunAdvancedPlugin(core, {
79
- enableDebug: enableGunDebug,
80
- enableConnectionMonitoring,
81
- defaultPageSize,
82
- connectionTimeout,
83
- debounceInterval,
84
- });
85
- registerPlugin(gunPlugin);
86
- }
87
- // Ensure gunPlugin is always available
88
- if (!gunPlugin) {
89
- throw new Error("Failed to initialize GunAdvancedPlugin");
90
- }
86
+ // Plugin registration removed - GunAdvancedPlugin no longer available
91
87
  return {
92
88
  core,
93
89
  options,
@@ -95,6 +91,6 @@ export function shogunConnector(options) {
95
91
  getCurrentProviderUrl,
96
92
  registerPlugin,
97
93
  hasPlugin,
98
- gunPlugin,
94
+ gunPlugin: null,
99
95
  };
100
96
  }
package/dist/index.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import { ShogunButton, ShogunButtonProvider, useShogun } from './components/ShogunButton';
2
2
  import { ShogunConnectorOptions, ShogunConnectorResult } from './interfaces/connector-options';
3
3
  import { shogunConnector } from './connector';
4
- import { GunAdvancedPlugin } from './plugins/GunAdvancedPlugin';
5
4
  export { ShogunButton, ShogunButtonProvider, useShogun };
6
5
  export { shogunConnector };
7
6
  export * from './interfaces/connector-options';
8
7
  export { ShogunConnectorOptions, ShogunConnectorResult };
9
- export { GunAdvancedPlugin };