@txnlab/use-wallet-solid 3.1.6 → 3.2.1

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/dist/dev.cjs CHANGED
@@ -8,18 +8,30 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
8
 
9
9
  var algosdk__default = /*#__PURE__*/_interopDefault(algosdk);
10
10
 
11
- // ../../node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/solid.js
11
+ // ../../node_modules/.pnpm/solid-js@1.8.22/node_modules/solid-js/dist/solid.js
12
12
  var sharedConfig = {
13
13
  context: void 0,
14
- registry: void 0
14
+ registry: void 0,
15
+ effects: void 0,
16
+ done: false,
17
+ getContextId() {
18
+ return getContextId(this.context.count);
19
+ },
20
+ getNextContextId() {
21
+ return getContextId(this.context.count++);
22
+ }
15
23
  };
24
+ function getContextId(count) {
25
+ const num = String(count), len = num.length - 1;
26
+ return sharedConfig.context.id + (len ? String.fromCharCode(96 + len) : "") + num;
27
+ }
16
28
  function setHydrateContext(context) {
17
29
  sharedConfig.context = context;
18
30
  }
19
31
  function nextHydrateContext() {
20
32
  return {
21
33
  ...sharedConfig.context,
22
- id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
34
+ id: sharedConfig.getNextContextId(),
23
35
  count: 0
24
36
  };
25
37
  }
@@ -55,10 +67,8 @@ function createSignal(value, options) {
55
67
  };
56
68
  const setter = (value2) => {
57
69
  if (typeof value2 === "function") {
58
- if (Transition && Transition.running && Transition.sources.has(s))
59
- value2 = value2(s.tValue);
60
- else
61
- value2 = value2(s.value);
70
+ if (Transition && Transition.running && Transition.sources.has(s)) value2 = value2(s.tValue);
71
+ else value2 = value2(s.value);
62
72
  }
63
73
  return writeSignal(s, value2);
64
74
  };
@@ -66,16 +76,13 @@ function createSignal(value, options) {
66
76
  }
67
77
  function createRenderEffect(fn, value, options) {
68
78
  const c = createComputation(fn, value, false, STALE);
69
- if (Scheduler && Transition && Transition.running)
70
- Updates.push(c);
71
- else
72
- updateComputation(c);
79
+ if (Scheduler && Transition && Transition.running) Updates.push(c);
80
+ else updateComputation(c);
73
81
  }
74
82
  function createEffect(fn, value, options) {
75
83
  runEffects = runUserEffects;
76
84
  const c = createComputation(fn, value, false, STALE), s = SuspenseContext && useContext(SuspenseContext);
77
- if (s)
78
- c.suspense = s;
85
+ if (s) c.suspense = s;
79
86
  c.user = true;
80
87
  Effects ? Effects.push(c) : updateComputation(c);
81
88
  }
@@ -88,18 +95,15 @@ function createMemo(fn, value, options) {
88
95
  if (Scheduler && Transition && Transition.running) {
89
96
  c.tState = STALE;
90
97
  Updates.push(c);
91
- } else
92
- updateComputation(c);
98
+ } else updateComputation(c);
93
99
  return readSignal.bind(c);
94
100
  }
95
101
  function untrack(fn) {
96
- if (!ExternalSourceConfig && Listener === null)
97
- return fn();
102
+ if (!ExternalSourceConfig && Listener === null) return fn();
98
103
  const listener = Listener;
99
104
  Listener = null;
100
105
  try {
101
- if (ExternalSourceConfig)
102
- return ExternalSourceConfig.untrack(fn);
106
+ if (ExternalSourceConfig) return ExternalSourceConfig.untrack(fn);
103
107
  return fn();
104
108
  } finally {
105
109
  Listener = listener;
@@ -109,12 +113,9 @@ function onMount(fn) {
109
113
  createEffect(() => untrack(fn));
110
114
  }
111
115
  function onCleanup(fn) {
112
- if (Owner === null)
113
- ;
114
- else if (Owner.cleanups === null)
115
- Owner.cleanups = [fn];
116
- else
117
- Owner.cleanups.push(fn);
116
+ if (Owner === null) ;
117
+ else if (Owner.cleanups === null) Owner.cleanups = [fn];
118
+ else Owner.cleanups.push(fn);
118
119
  return fn;
119
120
  }
120
121
  function startTransition(fn) {
@@ -155,7 +156,8 @@ function createContext(defaultValue, options) {
155
156
  };
156
157
  }
157
158
  function useContext(context) {
158
- return Owner && Owner.context && Owner.context[context.id] !== void 0 ? Owner.context[context.id] : context.defaultValue;
159
+ let value;
160
+ return Owner && Owner.context && (value = Owner.context[context.id]) !== void 0 ? value : context.defaultValue;
159
161
  }
160
162
  function children(fn) {
161
163
  const children2 = createMemo(fn);
@@ -170,8 +172,7 @@ var SuspenseContext;
170
172
  function readSignal() {
171
173
  const runningTransition = Transition && Transition.running;
172
174
  if (this.sources && (runningTransition ? this.tState : this.state)) {
173
- if ((runningTransition ? this.tState : this.state) === STALE)
174
- updateComputation(this);
175
+ if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
175
176
  else {
176
177
  const updates = Updates;
177
178
  Updates = null;
@@ -196,8 +197,7 @@ function readSignal() {
196
197
  this.observerSlots.push(Listener.sources.length - 1);
197
198
  }
198
199
  }
199
- if (runningTransition && Transition.sources.has(this))
200
- return this.tValue;
200
+ if (runningTransition && Transition.sources.has(this)) return this.tValue;
201
201
  return this.value;
202
202
  }
203
203
  function writeSignal(node, value, isComp) {
@@ -209,34 +209,25 @@ function writeSignal(node, value, isComp) {
209
209
  Transition.sources.add(node);
210
210
  node.tValue = value;
211
211
  }
212
- if (!TransitionRunning)
213
- node.value = value;
214
- } else
215
- node.value = value;
212
+ if (!TransitionRunning) node.value = value;
213
+ } else node.value = value;
216
214
  if (node.observers && node.observers.length) {
217
215
  runUpdates(() => {
218
216
  for (let i = 0; i < node.observers.length; i += 1) {
219
217
  const o = node.observers[i];
220
218
  const TransitionRunning = Transition && Transition.running;
221
- if (TransitionRunning && Transition.disposed.has(o))
222
- continue;
219
+ if (TransitionRunning && Transition.disposed.has(o)) continue;
223
220
  if (TransitionRunning ? !o.tState : !o.state) {
224
- if (o.pure)
225
- Updates.push(o);
226
- else
227
- Effects.push(o);
228
- if (o.observers)
229
- markDownstream(o);
221
+ if (o.pure) Updates.push(o);
222
+ else Effects.push(o);
223
+ if (o.observers) markDownstream(o);
230
224
  }
231
- if (!TransitionRunning)
232
- o.state = STALE;
233
- else
234
- o.tState = STALE;
225
+ if (!TransitionRunning) o.state = STALE;
226
+ else o.tState = STALE;
235
227
  }
236
228
  if (Updates.length > 1e6) {
237
229
  Updates = [];
238
- if (false)
239
- ;
230
+ if (false) ;
240
231
  throw new Error();
241
232
  }
242
233
  });
@@ -245,15 +236,10 @@ function writeSignal(node, value, isComp) {
245
236
  return value;
246
237
  }
247
238
  function updateComputation(node) {
248
- if (!node.fn)
249
- return;
239
+ if (!node.fn) return;
250
240
  cleanNode(node);
251
241
  const time = ExecCount;
252
- runComputation(
253
- node,
254
- Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
255
- time
256
- );
242
+ runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
257
243
  if (Transition && !Transition.running && Transition.sources.has(node)) {
258
244
  queueMicrotask(() => {
259
245
  runUpdates(() => {
@@ -295,8 +281,7 @@ function runComputation(node, value, time) {
295
281
  } else if (Transition && Transition.running && node.pure) {
296
282
  Transition.sources.add(node);
297
283
  node.tValue = nextValue;
298
- } else
299
- node.value = nextValue;
284
+ } else node.value = nextValue;
300
285
  node.updatedAt = time;
301
286
  }
302
287
  }
@@ -318,19 +303,14 @@ function createComputation(fn, init, pure, state = STALE, options) {
318
303
  c.state = 0;
319
304
  c.tState = state;
320
305
  }
321
- if (Owner === null)
322
- ;
306
+ if (Owner === null) ;
323
307
  else if (Owner !== UNOWNED) {
324
308
  if (Transition && Transition.running && Owner.pure) {
325
- if (!Owner.tOwned)
326
- Owner.tOwned = [c];
327
- else
328
- Owner.tOwned.push(c);
309
+ if (!Owner.tOwned) Owner.tOwned = [c];
310
+ else Owner.tOwned.push(c);
329
311
  } else {
330
- if (!Owner.owned)
331
- Owner.owned = [c];
332
- else
333
- Owner.owned.push(c);
312
+ if (!Owner.owned) Owner.owned = [c];
313
+ else Owner.owned.push(c);
334
314
  }
335
315
  }
336
316
  if (ExternalSourceConfig && c.fn) {
@@ -350,26 +330,20 @@ function createComputation(fn, init, pure, state = STALE, options) {
350
330
  }
351
331
  function runTop(node) {
352
332
  const runningTransition = Transition && Transition.running;
353
- if ((runningTransition ? node.tState : node.state) === 0)
354
- return;
355
- if ((runningTransition ? node.tState : node.state) === PENDING)
356
- return lookUpstream(node);
357
- if (node.suspense && untrack(node.suspense.inFallback))
358
- return node.suspense.effects.push(node);
333
+ if ((runningTransition ? node.tState : node.state) === 0) return;
334
+ if ((runningTransition ? node.tState : node.state) === PENDING) return lookUpstream(node);
335
+ if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
359
336
  const ancestors = [node];
360
337
  while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
361
- if (runningTransition && Transition.disposed.has(node))
362
- return;
363
- if (runningTransition ? node.tState : node.state)
364
- ancestors.push(node);
338
+ if (runningTransition && Transition.disposed.has(node)) return;
339
+ if (runningTransition ? node.tState : node.state) ancestors.push(node);
365
340
  }
366
341
  for (let i = ancestors.length - 1; i >= 0; i--) {
367
342
  node = ancestors[i];
368
343
  if (runningTransition) {
369
344
  let top = node, prev = ancestors[i + 1];
370
345
  while ((top = top.owner) && top !== prev) {
371
- if (Transition.disposed.has(top))
372
- return;
346
+ if (Transition.disposed.has(top)) return;
373
347
  }
374
348
  }
375
349
  if ((runningTransition ? node.tState : node.state) === STALE) {
@@ -383,36 +357,29 @@ function runTop(node) {
383
357
  }
384
358
  }
385
359
  function runUpdates(fn, init) {
386
- if (Updates)
387
- return fn();
360
+ if (Updates) return fn();
388
361
  let wait = false;
389
362
  Updates = [];
390
- if (Effects)
391
- wait = true;
392
- else
393
- Effects = [];
363
+ if (Effects) wait = true;
364
+ else Effects = [];
394
365
  ExecCount++;
395
366
  try {
396
367
  const res = fn();
397
368
  completeUpdates(wait);
398
369
  return res;
399
370
  } catch (err) {
400
- if (!wait)
401
- Effects = null;
371
+ if (!wait) Effects = null;
402
372
  Updates = null;
403
373
  handleError(err);
404
374
  }
405
375
  }
406
376
  function completeUpdates(wait) {
407
377
  if (Updates) {
408
- if (Scheduler && Transition && Transition.running)
409
- scheduleQueue(Updates);
410
- else
411
- runQueue(Updates);
378
+ if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
379
+ else runQueue(Updates);
412
380
  Updates = null;
413
381
  }
414
- if (wait)
415
- return;
382
+ if (wait) return;
416
383
  let res;
417
384
  if (Transition) {
418
385
  if (!Transition.promises.size && !Transition.queue.size) {
@@ -426,16 +393,13 @@ function completeUpdates(wait) {
426
393
  }
427
394
  Transition = null;
428
395
  runUpdates(() => {
429
- for (const d of disposed)
430
- cleanNode(d);
396
+ for (const d of disposed) cleanNode(d);
431
397
  for (const v of sources) {
432
398
  v.value = v.tValue;
433
399
  if (v.owned) {
434
- for (let i = 0, len = v.owned.length; i < len; i++)
435
- cleanNode(v.owned[i]);
400
+ for (let i = 0, len = v.owned.length; i < len; i++) cleanNode(v.owned[i]);
436
401
  }
437
- if (v.tOwned)
438
- v.owned = v.tOwned;
402
+ if (v.tOwned) v.owned = v.tOwned;
439
403
  delete v.tValue;
440
404
  delete v.tOwned;
441
405
  v.tState = 0;
@@ -452,14 +416,11 @@ function completeUpdates(wait) {
452
416
  }
453
417
  const e = Effects;
454
418
  Effects = null;
455
- if (e.length)
456
- runUpdates(() => runEffects(e));
457
- if (res)
458
- res();
419
+ if (e.length) runUpdates(() => runEffects(e));
420
+ if (res) res();
459
421
  }
460
422
  function runQueue(queue) {
461
- for (let i = 0; i < queue.length; i++)
462
- runTop(queue[i]);
423
+ for (let i = 0; i < queue.length; i++) runTop(queue[i]);
463
424
  }
464
425
  function scheduleQueue(queue) {
465
426
  for (let i = 0; i < queue.length; i++) {
@@ -482,41 +443,35 @@ function runUserEffects(queue) {
482
443
  let i, userLength = 0;
483
444
  for (i = 0; i < queue.length; i++) {
484
445
  const e = queue[i];
485
- if (!e.user)
486
- runTop(e);
487
- else
488
- queue[userLength++] = e;
446
+ if (!e.user) runTop(e);
447
+ else queue[userLength++] = e;
489
448
  }
490
449
  if (sharedConfig.context) {
491
450
  if (sharedConfig.count) {
492
451
  sharedConfig.effects || (sharedConfig.effects = []);
493
452
  sharedConfig.effects.push(...queue.slice(0, userLength));
494
453
  return;
495
- } else if (sharedConfig.effects) {
496
- queue = [...sharedConfig.effects, ...queue];
497
- userLength += sharedConfig.effects.length;
498
- delete sharedConfig.effects;
499
454
  }
500
455
  setHydrateContext();
501
456
  }
502
- for (i = 0; i < userLength; i++)
503
- runTop(queue[i]);
457
+ if (sharedConfig.effects && (sharedConfig.done || !sharedConfig.count)) {
458
+ queue = [...sharedConfig.effects, ...queue];
459
+ userLength += sharedConfig.effects.length;
460
+ delete sharedConfig.effects;
461
+ }
462
+ for (i = 0; i < userLength; i++) runTop(queue[i]);
504
463
  }
505
464
  function lookUpstream(node, ignore) {
506
465
  const runningTransition = Transition && Transition.running;
507
- if (runningTransition)
508
- node.tState = 0;
509
- else
510
- node.state = 0;
466
+ if (runningTransition) node.tState = 0;
467
+ else node.state = 0;
511
468
  for (let i = 0; i < node.sources.length; i += 1) {
512
469
  const source = node.sources[i];
513
470
  if (source.sources) {
514
471
  const state = runningTransition ? source.tState : source.state;
515
472
  if (state === STALE) {
516
- if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
517
- runTop(source);
518
- } else if (state === PENDING)
519
- lookUpstream(source, ignore);
473
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
474
+ } else if (state === PENDING) lookUpstream(source, ignore);
520
475
  }
521
476
  }
522
477
  }
@@ -525,14 +480,10 @@ function markDownstream(node) {
525
480
  for (let i = 0; i < node.observers.length; i += 1) {
526
481
  const o = node.observers[i];
527
482
  if (runningTransition ? !o.tState : !o.state) {
528
- if (runningTransition)
529
- o.tState = PENDING;
530
- else
531
- o.state = PENDING;
532
- if (o.pure)
533
- Updates.push(o);
534
- else
535
- Effects.push(o);
483
+ if (runningTransition) o.tState = PENDING;
484
+ else o.state = PENDING;
485
+ if (o.pure) Updates.push(o);
486
+ else Effects.push(o);
536
487
  o.observers && markDownstream(o);
537
488
  }
538
489
  }
@@ -554,25 +505,20 @@ function cleanNode(node) {
554
505
  }
555
506
  if (Transition && Transition.running && node.pure) {
556
507
  if (node.tOwned) {
557
- for (i = node.tOwned.length - 1; i >= 0; i--)
558
- cleanNode(node.tOwned[i]);
508
+ for (i = node.tOwned.length - 1; i >= 0; i--) cleanNode(node.tOwned[i]);
559
509
  delete node.tOwned;
560
510
  }
561
511
  reset(node, true);
562
512
  } else if (node.owned) {
563
- for (i = node.owned.length - 1; i >= 0; i--)
564
- cleanNode(node.owned[i]);
513
+ for (i = node.owned.length - 1; i >= 0; i--) cleanNode(node.owned[i]);
565
514
  node.owned = null;
566
515
  }
567
516
  if (node.cleanups) {
568
- for (i = node.cleanups.length - 1; i >= 0; i--)
569
- node.cleanups[i]();
517
+ for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
570
518
  node.cleanups = null;
571
519
  }
572
- if (Transition && Transition.running)
573
- node.tState = 0;
574
- else
575
- node.state = 0;
520
+ if (Transition && Transition.running) node.tState = 0;
521
+ else node.state = 0;
576
522
  }
577
523
  function reset(node, top) {
578
524
  if (!top) {
@@ -580,21 +526,18 @@ function reset(node, top) {
580
526
  Transition.disposed.add(node);
581
527
  }
582
528
  if (node.owned) {
583
- for (let i = 0; i < node.owned.length; i++)
584
- reset(node.owned[i]);
529
+ for (let i = 0; i < node.owned.length; i++) reset(node.owned[i]);
585
530
  }
586
531
  }
587
532
  function castError(err) {
588
- if (err instanceof Error)
589
- return err;
533
+ if (err instanceof Error) return err;
590
534
  return new Error(typeof err === "string" ? err : "Unknown error", {
591
535
  cause: err
592
536
  });
593
537
  }
594
538
  function runErrors(err, fns, owner) {
595
539
  try {
596
- for (const f of fns)
597
- f(err);
540
+ for (const f of fns) f(err);
598
541
  } catch (e) {
599
542
  handleError(e, owner && owner.owner || null);
600
543
  }
@@ -602,21 +545,17 @@ function runErrors(err, fns, owner) {
602
545
  function handleError(err, owner = Owner) {
603
546
  const fns = ERROR && owner && owner.context && owner.context[ERROR];
604
547
  const error = castError(err);
605
- if (!fns)
606
- throw error;
607
- if (Effects)
608
- Effects.push({
609
- fn() {
610
- runErrors(error, fns, owner);
611
- },
612
- state: STALE
613
- });
614
- else
615
- runErrors(error, fns, owner);
548
+ if (!fns) throw error;
549
+ if (Effects) Effects.push({
550
+ fn() {
551
+ runErrors(error, fns, owner);
552
+ },
553
+ state: STALE
554
+ });
555
+ else runErrors(error, fns, owner);
616
556
  }
617
557
  function resolveChildren(children2) {
618
- if (typeof children2 === "function" && !children2.length)
619
- return resolveChildren(children2());
558
+ if (typeof children2 === "function" && !children2.length) return resolveChildren(children2());
620
559
  if (Array.isArray(children2)) {
621
560
  const results = [];
622
561
  for (let i = 0; i < children2.length; i++) {
@@ -630,16 +569,13 @@ function resolveChildren(children2) {
630
569
  function createProvider(id, options) {
631
570
  return function provider(props) {
632
571
  let res;
633
- createRenderEffect(
634
- () => res = untrack(() => {
635
- Owner.context = {
636
- ...Owner.context,
637
- [id]: props.value
638
- };
639
- return children(() => props.children);
640
- }),
641
- void 0
642
- );
572
+ createRenderEffect(() => res = untrack(() => {
573
+ Owner.context = {
574
+ ...Owner.context,
575
+ [id]: props.value
576
+ };
577
+ return children(() => props.children);
578
+ }), void 0);
643
579
  return res;
644
580
  };
645
581
  }
@@ -657,44 +593,9 @@ function createComponent(Comp, props) {
657
593
  return untrack(() => Comp(props || {}));
658
594
  }
659
595
 
660
- // ../../node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/web/dist/web.js
661
- var booleans = [
662
- "allowfullscreen",
663
- "async",
664
- "autofocus",
665
- "autoplay",
666
- "checked",
667
- "controls",
668
- "default",
669
- "disabled",
670
- "formnovalidate",
671
- "hidden",
672
- "indeterminate",
673
- "inert",
674
- "ismap",
675
- "loop",
676
- "multiple",
677
- "muted",
678
- "nomodule",
679
- "novalidate",
680
- "open",
681
- "playsinline",
682
- "readonly",
683
- "required",
684
- "reversed",
685
- "seamless",
686
- "selected"
687
- ];
688
- /* @__PURE__ */ new Set([
689
- "className",
690
- "value",
691
- "readOnly",
692
- "formNoValidate",
693
- "isMap",
694
- "noModule",
695
- "playsInline",
696
- ...booleans
697
- ]);
596
+ // ../../node_modules/.pnpm/solid-js@1.8.22/node_modules/solid-js/web/dist/web.js
597
+ var booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "inert", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
598
+ /* @__PURE__ */ new Set(["className", "value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
698
599
  var WalletContext = createContext();
699
600
  exports.WalletProvider = (props) => {
700
601
  const store = () => props.manager;
@@ -746,7 +647,6 @@ function useWallet() {
746
647
  headers
747
648
  } = manager().networkConfig[networkId];
748
649
  const newClient = new algosdk__default.default.Algodv2(token, baseServer, port, headers);
749
- manager().algodClient = newClient;
750
650
  manager().store.setState((state) => ({
751
651
  ...state,
752
652
  activeNetwork: networkId,