@velora-dex/widget 0.3.11 → 0.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,3 +1,3 @@
1
1
  import { WidgetProps } from './types';
2
- export declare const Widget: ({ config, provider, events, input }: WidgetProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const Widget: ({ config, apiConfig, provider, events, input, }: WidgetProps) => import("react/jsx-runtime").JSX.Element;
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.tsx"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiB7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAgV3C,eAAO,MAAM,MAAM,GAAI,qCAAqC,WAAW,4CAatE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.tsx"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiB7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AA4V3C,eAAO,MAAM,MAAM,GAAI,iDAMpB,WAAW,4CAcb,CAAC"}
@@ -70,6 +70,7 @@ import { isBridgePrice } from '../hooks/swap/prices/delta/queries/useDeltaPriceQ
70
70
  import { BridgeSelectorExpandable } from '../components/widget/BridgeSelectorExpandable/BridgeSelectorExpandable.js';
71
71
  import { ErrorBoundary } from 'react-error-boundary';
72
72
  import { useInitialValue } from './screen/hooks/useInitialValue.js';
73
+ import { apiConfigAtom } from './state/apiConfigAtom.js';
73
74
 
74
75
  runSubscriptions();
75
76
  const SwapScreen = () => {
@@ -279,9 +280,10 @@ const App = () => {
279
280
  return t2;
280
281
  };
281
282
  const WidgetBase = (t0) => {
282
- const $ = distExports.c(73);
283
+ const $ = distExports.c(86);
283
284
  const {
284
285
  config: _config,
286
+ apiConfig,
285
287
  provider,
286
288
  events,
287
289
  input: formInputProps
@@ -289,6 +291,7 @@ const WidgetBase = (t0) => {
289
291
  const queryClient = useQueryClient();
290
292
  const setWidgetConfig = useSetAtom(setWidgetConfigAtom);
291
293
  const setSubConfig = useSetAtom(setSubConfigAtom);
294
+ const setApiConfig = useSetAtom(apiConfigAtom);
292
295
  let t1;
293
296
  if ($[0] !== _config) {
294
297
  t1 = _config || {};
@@ -369,84 +372,101 @@ const WidgetBase = (t0) => {
369
372
  } else {
370
373
  t3 = $[20];
371
374
  }
372
- const t4 = provider || null;
373
- let t5;
374
- if ($[21] !== t4) {
375
- t5 = [externalProviderAtom, t4];
376
- $[21] = t4;
377
- $[22] = t5;
375
+ let t4;
376
+ if ($[21] !== apiConfig) {
377
+ t4 = apiConfig || {};
378
+ $[21] = apiConfig;
379
+ $[22] = t4;
378
380
  } else {
379
- t5 = $[22];
381
+ t4 = $[22];
380
382
  }
381
- let t6;
382
- if ($[23] !== events) {
383
- t6 = events || {};
384
- $[23] = events;
385
- $[24] = t6;
383
+ let t5;
384
+ if ($[23] !== t4) {
385
+ t5 = [apiConfigAtom, t4];
386
+ $[23] = t4;
387
+ $[24] = t5;
386
388
  } else {
387
- t6 = $[24];
389
+ t5 = $[24];
388
390
  }
391
+ const t6 = provider || null;
389
392
  let t7;
390
393
  if ($[25] !== t6) {
391
- t7 = [widgetEventsAtom, t6];
394
+ t7 = [externalProviderAtom, t6];
392
395
  $[25] = t6;
393
396
  $[26] = t7;
394
397
  } else {
395
398
  t7 = $[26];
396
399
  }
397
400
  let t8;
398
- if ($[27] !== formInputProps) {
399
- t8 = formInputProps || {};
400
- $[27] = formInputProps;
401
+ if ($[27] !== events) {
402
+ t8 = events || {};
403
+ $[27] = events;
401
404
  $[28] = t8;
402
405
  } else {
403
406
  t8 = $[28];
404
407
  }
405
408
  let t9;
406
409
  if ($[29] !== t8) {
407
- t9 = [formInputPropsAtom, t8];
410
+ t9 = [widgetEventsAtom, t8];
408
411
  $[29] = t8;
409
412
  $[30] = t9;
410
413
  } else {
411
414
  t9 = $[30];
412
415
  }
413
416
  let t10;
414
- if ($[31] !== queryClient) {
415
- t10 = [queryClientAtom, queryClient];
416
- $[31] = queryClient;
417
+ if ($[31] !== formInputProps) {
418
+ t10 = formInputProps || {};
419
+ $[31] = formInputProps;
417
420
  $[32] = t10;
418
421
  } else {
419
422
  t10 = $[32];
420
423
  }
421
424
  let t11;
422
- if ($[33] !== t10 || $[34] !== t2 || $[35] !== t3 || $[36] !== t5 || $[37] !== t7 || $[38] !== t9) {
423
- t11 = [t2, t3, t5, t7, t9, t10];
425
+ if ($[33] !== t10) {
426
+ t11 = [formInputPropsAtom, t10];
424
427
  $[33] = t10;
425
- $[34] = t2;
426
- $[35] = t3;
427
- $[36] = t5;
428
- $[37] = t7;
429
- $[38] = t9;
430
- $[39] = t11;
428
+ $[34] = t11;
431
429
  } else {
432
- t11 = $[39];
430
+ t11 = $[34];
433
431
  }
434
432
  let t12;
435
- if ($[40] === Symbol.for("react.memo_cache_sentinel")) {
436
- t12 = {
433
+ if ($[35] !== queryClient) {
434
+ t12 = [queryClientAtom, queryClient];
435
+ $[35] = queryClient;
436
+ $[36] = t12;
437
+ } else {
438
+ t12 = $[36];
439
+ }
440
+ let t13;
441
+ if ($[37] !== t11 || $[38] !== t12 || $[39] !== t2 || $[40] !== t3 || $[41] !== t5 || $[42] !== t7 || $[43] !== t9) {
442
+ t13 = [t2, t3, t5, t7, t9, t11, t12];
443
+ $[37] = t11;
444
+ $[38] = t12;
445
+ $[39] = t2;
446
+ $[40] = t3;
447
+ $[41] = t5;
448
+ $[42] = t7;
449
+ $[43] = t9;
450
+ $[44] = t13;
451
+ } else {
452
+ t13 = $[44];
453
+ }
454
+ let t14;
455
+ if ($[45] === Symbol.for("react.memo_cache_sentinel")) {
456
+ t14 = {
437
457
  store: jotaiStore
438
458
  };
439
- $[40] = t12;
459
+ $[45] = t14;
440
460
  } else {
441
- t12 = $[40];
461
+ t14 = $[45];
442
462
  }
443
- useHydrateAtoms(t11, t12);
463
+ useHydrateAtoms(t13, t14);
444
464
  useWidgetEventsSetter(events);
445
465
  useSetFormInputFromProps(formInputProps);
446
- let t13;
447
- let t14;
448
- if ($[41] !== config.debug || $[42] !== config.enableCrossChain || $[43] !== config.enableDelta || $[44] !== config.ignoreBadUsdPrice || $[45] !== config.privyAppId || $[46] !== config.privyClientId || $[47] !== config.theme || $[48] !== config.widgetMode || $[49] !== setWidgetConfig) {
449
- t13 = () => {
466
+ let t15;
467
+ let t16;
468
+ if ($[46] !== config.debug || $[47] !== config.enableCrossChain || $[48] !== config.enableDelta || $[49] !== config.ignoreBadUsdPrice || $[50] !== config.privyAppId || $[51] !== config.privyClientId || $[52] !== config.theme || $[53] !== config.widgetMode || $[54] !== setWidgetConfig) {
469
+ t15 = () => {
450
470
  setWidgetConfig({
451
471
  theme: config.theme,
452
472
  enableDelta: config.enableDelta,
@@ -458,27 +478,27 @@ const WidgetBase = (t0) => {
458
478
  ignoreBadUsdPrice: config.ignoreBadUsdPrice
459
479
  });
460
480
  };
461
- t14 = [config.theme, config.enableDelta, config.enableCrossChain, config.privyAppId, config.privyClientId, config.debug, config.widgetMode, config.ignoreBadUsdPrice, setWidgetConfig];
462
- $[41] = config.debug;
463
- $[42] = config.enableCrossChain;
464
- $[43] = config.enableDelta;
465
- $[44] = config.ignoreBadUsdPrice;
466
- $[45] = config.privyAppId;
467
- $[46] = config.privyClientId;
468
- $[47] = config.theme;
469
- $[48] = config.widgetMode;
470
- $[49] = setWidgetConfig;
471
- $[50] = t13;
472
- $[51] = t14;
473
- } else {
474
- t13 = $[50];
475
- t14 = $[51];
476
- }
477
- useLayoutEffect(t13, t14);
478
- let t15;
479
- let t16;
480
- if ($[52] !== destChains || $[53] !== devURLs || $[54] !== excludeUI || $[55] !== partnerConfig || $[56] !== setSubConfig || $[57] !== srcChains || $[58] !== tokenLists || $[59] !== tradeModes) {
481
- t15 = () => {
481
+ t16 = [config.theme, config.enableDelta, config.enableCrossChain, config.privyAppId, config.privyClientId, config.debug, config.widgetMode, config.ignoreBadUsdPrice, setWidgetConfig];
482
+ $[46] = config.debug;
483
+ $[47] = config.enableCrossChain;
484
+ $[48] = config.enableDelta;
485
+ $[49] = config.ignoreBadUsdPrice;
486
+ $[50] = config.privyAppId;
487
+ $[51] = config.privyClientId;
488
+ $[52] = config.theme;
489
+ $[53] = config.widgetMode;
490
+ $[54] = setWidgetConfig;
491
+ $[55] = t15;
492
+ $[56] = t16;
493
+ } else {
494
+ t15 = $[55];
495
+ t16 = $[56];
496
+ }
497
+ useLayoutEffect(t15, t16);
498
+ let t17;
499
+ let t18;
500
+ if ($[57] !== destChains || $[58] !== devURLs || $[59] !== excludeUI || $[60] !== partnerConfig || $[61] !== setSubConfig || $[62] !== srcChains || $[63] !== tokenLists || $[64] !== tradeModes) {
501
+ t17 = () => {
482
502
  setSubConfig({
483
503
  srcChains,
484
504
  destChains,
@@ -489,98 +509,128 @@ const WidgetBase = (t0) => {
489
509
  partnerConfig
490
510
  });
491
511
  };
492
- t16 = [srcChains, destChains, tokenLists, setSubConfig, tradeModes, excludeUI, devURLs, partnerConfig];
493
- $[52] = destChains;
494
- $[53] = devURLs;
495
- $[54] = excludeUI;
496
- $[55] = partnerConfig;
497
- $[56] = setSubConfig;
498
- $[57] = srcChains;
499
- $[58] = tokenLists;
500
- $[59] = tradeModes;
501
- $[60] = t15;
502
- $[61] = t16;
503
- } else {
504
- t15 = $[60];
505
- t16 = $[61];
512
+ t18 = [srcChains, destChains, tokenLists, setSubConfig, tradeModes, excludeUI, devURLs, partnerConfig];
513
+ $[57] = destChains;
514
+ $[58] = devURLs;
515
+ $[59] = excludeUI;
516
+ $[60] = partnerConfig;
517
+ $[61] = setSubConfig;
518
+ $[62] = srcChains;
519
+ $[63] = tokenLists;
520
+ $[64] = tradeModes;
521
+ $[65] = t17;
522
+ $[66] = t18;
523
+ } else {
524
+ t17 = $[65];
525
+ t18 = $[66];
506
526
  }
507
- useLayoutEffect(t15, t16);
527
+ useLayoutEffect(t17, t18);
528
+ let t19;
529
+ if ($[67] !== apiConfig?.apiKey || $[68] !== apiConfig?.headers || $[69] !== setApiConfig) {
530
+ t19 = () => {
531
+ setApiConfig({
532
+ apiKey: apiConfig?.apiKey,
533
+ headers: apiConfig?.headers
534
+ });
535
+ };
536
+ $[67] = apiConfig?.apiKey;
537
+ $[68] = apiConfig?.headers;
538
+ $[69] = setApiConfig;
539
+ $[70] = t19;
540
+ } else {
541
+ t19 = $[70];
542
+ }
543
+ const t20 = apiConfig?.apiKey;
544
+ const t21 = apiConfig?.headers;
545
+ let t22;
546
+ if ($[71] !== setApiConfig || $[72] !== t20 || $[73] !== t21) {
547
+ t22 = [t20, t21, setApiConfig];
548
+ $[71] = setApiConfig;
549
+ $[72] = t20;
550
+ $[73] = t21;
551
+ $[74] = t22;
552
+ } else {
553
+ t22 = $[74];
554
+ }
555
+ useLayoutEffect(t19, t22);
508
556
  const setExternalProvider = useSetAtom(externalProviderAtom);
509
- let t17;
510
- let t18;
511
- if ($[62] !== provider || $[63] !== setExternalProvider) {
512
- t17 = () => {
557
+ let t23;
558
+ let t24;
559
+ if ($[75] !== provider || $[76] !== setExternalProvider) {
560
+ t23 = () => {
513
561
  setExternalProvider(provider || null);
514
562
  };
515
- t18 = [provider, setExternalProvider];
516
- $[62] = provider;
517
- $[63] = setExternalProvider;
518
- $[64] = t17;
519
- $[65] = t18;
563
+ t24 = [provider, setExternalProvider];
564
+ $[75] = provider;
565
+ $[76] = setExternalProvider;
566
+ $[77] = t23;
567
+ $[78] = t24;
520
568
  } else {
521
- t17 = $[64];
522
- t18 = $[65];
569
+ t23 = $[77];
570
+ t24 = $[78];
523
571
  }
524
- useLayoutEffect(t17, t18);
572
+ useLayoutEffect(t23, t24);
525
573
  const isDappMode = config?.widgetMode === "dapp";
526
574
  const reconnectOnMountInit = useInitialValue(!isDappMode);
527
- let t19;
528
- let t20;
529
- let t21;
530
- let t22;
531
- let t23;
532
- if ($[66] === Symbol.for("react.memo_cache_sentinel")) {
533
- t19 = /* @__PURE__ */ jsx(AutoconnectExternalProvider, {});
534
- t20 = /* @__PURE__ */ jsx(PrivyIframeDependency, {});
535
- t21 = /* @__PURE__ */ jsx(Updaters, {});
536
- t22 = /* @__PURE__ */ jsx(App, {});
537
- t23 = false;
538
- $[66] = t19;
539
- $[67] = t20;
540
- $[68] = t21;
541
- $[69] = t22;
542
- $[70] = t23;
543
- } else {
544
- t19 = $[66];
545
- t20 = $[67];
546
- t21 = $[68];
547
- t22 = $[69];
548
- t23 = $[70];
549
- }
550
- let t24;
551
- if ($[71] !== reconnectOnMountInit) {
552
- t24 = /* @__PURE__ */ jsxs(Web3Providers, { reconnectOnMount: reconnectOnMountInit, children: [
553
- t19,
554
- t20,
555
- t21,
556
- t22,
557
- t23
575
+ let t25;
576
+ let t26;
577
+ let t27;
578
+ let t28;
579
+ let t29;
580
+ if ($[79] === Symbol.for("react.memo_cache_sentinel")) {
581
+ t25 = /* @__PURE__ */ jsx(AutoconnectExternalProvider, {});
582
+ t26 = /* @__PURE__ */ jsx(PrivyIframeDependency, {});
583
+ t27 = /* @__PURE__ */ jsx(Updaters, {});
584
+ t28 = /* @__PURE__ */ jsx(App, {});
585
+ t29 = false;
586
+ $[79] = t25;
587
+ $[80] = t26;
588
+ $[81] = t27;
589
+ $[82] = t28;
590
+ $[83] = t29;
591
+ } else {
592
+ t25 = $[79];
593
+ t26 = $[80];
594
+ t27 = $[81];
595
+ t28 = $[82];
596
+ t29 = $[83];
597
+ }
598
+ let t30;
599
+ if ($[84] !== reconnectOnMountInit) {
600
+ t30 = /* @__PURE__ */ jsxs(Web3Providers, { reconnectOnMount: reconnectOnMountInit, children: [
601
+ t25,
602
+ t26,
603
+ t27,
604
+ t28,
605
+ t29
558
606
  ] });
559
- $[71] = reconnectOnMountInit;
560
- $[72] = t24;
607
+ $[84] = reconnectOnMountInit;
608
+ $[85] = t30;
561
609
  } else {
562
- t24 = $[72];
610
+ t30 = $[85];
563
611
  }
564
- return t24;
612
+ return t30;
565
613
  };
566
614
  const Widget = (t0) => {
567
- const $ = distExports.c(5);
615
+ const $ = distExports.c(6);
568
616
  const {
569
617
  config,
618
+ apiConfig,
570
619
  provider,
571
620
  events,
572
621
  input
573
622
  } = t0;
574
623
  let t1;
575
- if ($[0] !== config || $[1] !== events || $[2] !== input || $[3] !== provider) {
576
- t1 = /* @__PURE__ */ jsx(JotaiProvider, { children: /* @__PURE__ */ jsx(QueryClientProvider, { children: /* @__PURE__ */ jsx(WidgetBase, { config, provider, events, input }) }) });
577
- $[0] = config;
578
- $[1] = events;
579
- $[2] = input;
580
- $[3] = provider;
581
- $[4] = t1;
582
- } else {
583
- t1 = $[4];
624
+ if ($[0] !== apiConfig || $[1] !== config || $[2] !== events || $[3] !== input || $[4] !== provider) {
625
+ t1 = /* @__PURE__ */ jsx(JotaiProvider, { children: /* @__PURE__ */ jsx(QueryClientProvider, { children: /* @__PURE__ */ jsx(WidgetBase, { config, apiConfig, provider, events, input }) }) });
626
+ $[0] = apiConfig;
627
+ $[1] = config;
628
+ $[2] = events;
629
+ $[3] = input;
630
+ $[4] = provider;
631
+ $[5] = t1;
632
+ } else {
633
+ t1 = $[5];
584
634
  }
585
635
  return t1;
586
636
  };