shogun-button-react 1.3.10 → 1.3.12

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.
@@ -1,9 +1,12 @@
1
1
  import React from 'react';
2
- export class GunAdvancedPlugin {
3
- constructor(sdk, config = {}) {
2
+ import { BasePlugin } from "shogun-core";
3
+ export class GunAdvancedPlugin extends BasePlugin {
4
+ constructor(core, config = {}) {
5
+ super();
6
+ this.name = "gun-advanced";
4
7
  this.connectionMonitors = new Map();
5
8
  this.collectionCache = new Map();
6
- this.sdk = sdk;
9
+ this.core = core;
7
10
  this.config = {
8
11
  enableDebug: true,
9
12
  enableConnectionMonitoring: true,
@@ -39,11 +42,11 @@ export class GunAdvancedPlugin {
39
42
  const isMounted = React.useRef(true);
40
43
  React.useEffect(() => {
41
44
  var _a;
42
- if (!((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) || !this.sdk.isLoggedIn())
45
+ if (!((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn())
43
46
  return;
44
47
  setIsLoading(true);
45
48
  setError(null);
46
- const gunRef = this.sdk.gun.get(path);
49
+ const gunRef = this.core.gun.get(path);
47
50
  const off = gunRef.on((item) => {
48
51
  if (!isMounted.current)
49
52
  return;
@@ -69,14 +72,14 @@ export class GunAdvancedPlugin {
69
72
  }, [path]);
70
73
  const update = async (updates) => {
71
74
  var _a;
72
- if (!((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) || !this.sdk.isLoggedIn()) {
75
+ if (!((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn()) {
73
76
  throw new Error('SDK not initialized or user not logged in');
74
77
  }
75
78
  try {
76
79
  setError(null);
77
80
  const newData = { ...data, ...updates };
78
81
  await new Promise((resolve, reject) => {
79
- this.sdk.gun.get(path).put(newData, (ack) => {
82
+ this.core.gun.get(path).put(newData, (ack) => {
80
83
  if (ack.err) {
81
84
  reject(new Error(ack.err));
82
85
  }
@@ -96,13 +99,13 @@ export class GunAdvancedPlugin {
96
99
  };
97
100
  const set = async (newData) => {
98
101
  var _a;
99
- if (!((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) || !this.sdk.isLoggedIn()) {
102
+ if (!((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn()) {
100
103
  throw new Error('SDK not initialized or user not logged in');
101
104
  }
102
105
  try {
103
106
  setError(null);
104
107
  await new Promise((resolve, reject) => {
105
- this.sdk.gun.get(path).put(newData, (ack) => {
108
+ this.core.gun.get(path).put(newData, (ack) => {
106
109
  if (ack.err) {
107
110
  reject(new Error(ack.err));
108
111
  }
@@ -122,13 +125,13 @@ export class GunAdvancedPlugin {
122
125
  };
123
126
  const remove = async () => {
124
127
  var _a;
125
- if (!((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) || !this.sdk.isLoggedIn()) {
128
+ if (!((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn()) {
126
129
  throw new Error('SDK not initialized or user not logged in');
127
130
  }
128
131
  try {
129
132
  setError(null);
130
133
  await new Promise((resolve, reject) => {
131
- this.sdk.gun.get(path).put(null, (ack) => {
134
+ this.core.gun.get(path).put(null, (ack) => {
132
135
  if (ack.err) {
133
136
  reject(new Error(ack.err));
134
137
  }
@@ -151,8 +154,8 @@ export class GunAdvancedPlugin {
151
154
  var _a;
152
155
  setIsLoading(true);
153
156
  setError(null);
154
- if ((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) {
155
- this.sdk.gun.get(path).once(() => { });
157
+ if ((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) {
158
+ this.core.gun.get(path).once(() => { });
156
159
  }
157
160
  };
158
161
  return {
@@ -176,11 +179,11 @@ export class GunAdvancedPlugin {
176
179
  const cacheKey = `${path}-${JSON.stringify(options)}`;
177
180
  React.useEffect(() => {
178
181
  var _a;
179
- if (!((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) || !this.sdk.isLoggedIn())
182
+ if (!((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn())
180
183
  return;
181
184
  setIsLoading(true);
182
185
  setError(null);
183
- const gunRef = this.sdk.gun.get(path);
186
+ const gunRef = this.core.gun.get(path);
184
187
  const tempItems = [];
185
188
  const processItems = (items) => {
186
189
  if (!isMounted.current)
@@ -255,19 +258,19 @@ export class GunAdvancedPlugin {
255
258
  setIsLoading(true);
256
259
  setError(null);
257
260
  this.collectionCache.delete(cacheKey);
258
- if ((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) {
259
- this.sdk.gun.get(path).once(() => { });
261
+ if ((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) {
262
+ this.core.gun.get(path).once(() => { });
260
263
  }
261
264
  };
262
265
  const addItem = async (item) => {
263
266
  var _a;
264
- if (!((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) || !this.sdk.isLoggedIn()) {
267
+ if (!((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn()) {
265
268
  throw new Error('SDK not initialized or user not logged in');
266
269
  }
267
270
  try {
268
271
  setError(null);
269
272
  await new Promise((resolve, reject) => {
270
- this.sdk.gun.get(path).set(item, (ack) => {
273
+ this.core.gun.get(path).set(item, (ack) => {
271
274
  if (ack.err) {
272
275
  reject(new Error(ack.err));
273
276
  }
@@ -288,13 +291,13 @@ export class GunAdvancedPlugin {
288
291
  };
289
292
  const updateItem = async (id, updates) => {
290
293
  var _a;
291
- if (!((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) || !this.sdk.isLoggedIn()) {
294
+ if (!((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn()) {
292
295
  throw new Error('SDK not initialized or user not logged in');
293
296
  }
294
297
  try {
295
298
  setError(null);
296
299
  await new Promise((resolve, reject) => {
297
- this.sdk.gun.get(path).get(id).put(updates, (ack) => {
300
+ this.core.gun.get(path).get(id).put(updates, (ack) => {
298
301
  if (ack.err) {
299
302
  reject(new Error(ack.err));
300
303
  }
@@ -315,13 +318,13 @@ export class GunAdvancedPlugin {
315
318
  };
316
319
  const removeItem = async (id) => {
317
320
  var _a;
318
- if (!((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) || !this.sdk.isLoggedIn()) {
321
+ if (!((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn()) {
319
322
  throw new Error('SDK not initialized or user not logged in');
320
323
  }
321
324
  try {
322
325
  setError(null);
323
326
  await new Promise((resolve, reject) => {
324
- this.sdk.gun.get(path).get(id).put(null, (ack) => {
327
+ this.core.gun.get(path).get(id).put(null, (ack) => {
325
328
  if (ack.err) {
326
329
  reject(new Error(ack.err));
327
330
  }
@@ -363,10 +366,10 @@ export class GunAdvancedPlugin {
363
366
  const [error, setError] = React.useState(null);
364
367
  React.useEffect(() => {
365
368
  var _a;
366
- if (!this.config.enableConnectionMonitoring || !((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) || !this.sdk.isLoggedIn())
369
+ if (!this.config.enableConnectionMonitoring || !((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn())
367
370
  return;
368
371
  let timeoutId;
369
- const gunRef = this.sdk.gun.get(path);
372
+ const gunRef = this.core.gun.get(path);
370
373
  const resetTimeout = () => {
371
374
  clearTimeout(timeoutId);
372
375
  timeoutId = window.setTimeout(() => {
@@ -396,10 +399,10 @@ export class GunAdvancedPlugin {
396
399
  useGunDebug(path, enabled = true) {
397
400
  React.useEffect(() => {
398
401
  var _a;
399
- if (!enabled || !this.debugEnabled || !((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) || !this.sdk.isLoggedIn())
402
+ if (!enabled || !this.debugEnabled || !((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn())
400
403
  return;
401
404
  this.log(`Debug mode enabled for ${path}`);
402
- const gunRef = this.sdk.gun.get(path);
405
+ const gunRef = this.core.gun.get(path);
403
406
  const off = gunRef.on((data, key) => {
404
407
  this.log(`[${path}] Update:`, {
405
408
  key,
@@ -419,9 +422,9 @@ export class GunAdvancedPlugin {
419
422
  const [key, setKey] = React.useState(null);
420
423
  React.useEffect(() => {
421
424
  var _a;
422
- if (!((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) || !this.sdk.isLoggedIn())
425
+ if (!((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn())
423
426
  return;
424
- const gunRef = this.sdk.gun.get(path);
427
+ const gunRef = this.core.gun.get(path);
425
428
  const off = gunRef.on((item, itemKey) => {
426
429
  if (item) {
427
430
  setData(item);
@@ -441,11 +444,11 @@ export class GunAdvancedPlugin {
441
444
  }
442
445
  async put(path, data) {
443
446
  var _a;
444
- if (!((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) || !this.sdk.isLoggedIn()) {
447
+ if (!((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn()) {
445
448
  throw new Error('SDK not initialized or user not logged in');
446
449
  }
447
450
  return new Promise((resolve, reject) => {
448
- this.sdk.gun.get(path).put(data, (ack) => {
451
+ this.core.gun.get(path).put(data, (ack) => {
449
452
  if (ack.err) {
450
453
  reject(new Error(ack.err));
451
454
  }
@@ -457,17 +460,17 @@ export class GunAdvancedPlugin {
457
460
  }
458
461
  get(path) {
459
462
  var _a;
460
- if (!((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) || !this.sdk.isLoggedIn())
463
+ if (!((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn())
461
464
  return null;
462
- return this.sdk.gun.get(path);
465
+ return this.core.gun.get(path);
463
466
  }
464
467
  async remove(path) {
465
468
  var _a;
466
- if (!((_a = this.sdk) === null || _a === void 0 ? void 0 : _a.gun) || !this.sdk.isLoggedIn()) {
469
+ if (!((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn()) {
467
470
  throw new Error('SDK not initialized or user not logged in');
468
471
  }
469
472
  return new Promise((resolve, reject) => {
470
- this.sdk.gun.get(path).put(null, (ack) => {
473
+ this.core.gun.get(path).put(null, (ack) => {
471
474
  if (ack.err) {
472
475
  reject(new Error(ack.err));
473
476
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shogun-button-react",
3
3
  "description": "Shogun connector button",
4
- "version": "1.3.10",
4
+ "version": "1.3.12",
5
5
  "files": [
6
6
  "dist",
7
7
  "src/styles/index.css"
@@ -34,7 +34,7 @@
34
34
  "ethers": "^6.13.5",
35
35
  "prettier": "^3.5.3",
36
36
  "rxjs": "^7.8.1",
37
- "shogun-core": "^1.3.8"
37
+ "shogun-core": "^1.5.0"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": "^18.0.0",
@@ -1,3 +0,0 @@
1
- export * from './connector-options.js';
2
- import { AuthResult, SignUpResult } from 'shogun-core';
3
- export { AuthResult, SignUpResult };
@@ -1,4 +0,0 @@
1
- // Export the connector options
2
- export * from './connector-options.js';
3
- // Export any type extensions/declarations
4
- // Note: .d.ts files don't need .js extension in imports
package/dist/types.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './types/connector-options.js';
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- // Re-export connector options from the connector-options.ts file
2
- export * from './types/connector-options.js';