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